router: reimplement peer identification

The new implementation allows one to send messages through
a router socket to a peer even before receiving
messages from this peer.

Fixes issue #304
This commit is contained in:
Martin Hurton
2012-04-02 19:51:37 +02:00
parent 476c9b97c9
commit f037290dc3
2 changed files with 133 additions and 121 deletions

View File

@@ -65,15 +65,21 @@ namespace zmq
private:
// Receive peer id and update lookup map
bool identify_peer (pipe_t *pipe_);
// Fair queueing object for inbound pipes.
fq_t fq;
// This value is either 0 (nothing is prefetched), 1 (only message body
// is prefetched) or 2 (both identity and message body are prefetched).
int prefetched;
// True iff there is a message held in the pre-fetch buffer.
bool prefetched;
// If true, the receiver got the message part with
// the peer's identity.
bool identity_sent;
// Holds the prefetched identity.
blob_t prefetched_id;
msg_t prefetched_id;
// Holds the prefetched message.
msg_t prefetched_msg;
@@ -87,6 +93,9 @@ namespace zmq
bool active;
};
// We keep a set of pipes that have not been identified yet.
std::set <pipe_t*> anonymous_pipes;
// Outbound pipes indexed by the peer IDs.
typedef std::map <blob_t, outpipe_t> outpipes_t;
outpipes_t outpipes;