mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +08:00
Merge pull request #838 from Prarrot/master
Fixed compile issue with missing member of socket_base. Changed ZMQ_NEX...
This commit is contained in:
commit
5f07d103a7
@ -293,7 +293,7 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
|
|||||||
#define ZMQ_IPC_FILTER_PID 58
|
#define ZMQ_IPC_FILTER_PID 58
|
||||||
#define ZMQ_IPC_FILTER_UID 59
|
#define ZMQ_IPC_FILTER_UID 59
|
||||||
#define ZMQ_IPC_FILTER_GID 60
|
#define ZMQ_IPC_FILTER_GID 60
|
||||||
#define ZMQ_NEXT_IDENTITY 61
|
#define ZMQ_NEXT_CONNECT_PEER_ID 61
|
||||||
/* Message options */
|
/* Message options */
|
||||||
#define ZMQ_MORE 1
|
#define ZMQ_MORE 1
|
||||||
#define ZMQ_SRCFD 2
|
#define ZMQ_SRCFD 2
|
||||||
|
@ -88,7 +88,7 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
|
|||||||
int value = is_int? *((int *) optval_): 0;
|
int value = is_int? *((int *) optval_): 0;
|
||||||
|
|
||||||
switch (option_) {
|
switch (option_) {
|
||||||
case ZMQ_NEXT_IDENTITY:
|
case ZMQ_NEXT_CONNECT_PEER_ID:
|
||||||
if(optval_ && optvallen_) {
|
if(optval_ && optvallen_) {
|
||||||
next_identity.assign((char*)optval_,optvallen_);
|
next_identity.assign((char*)optval_,optvallen_);
|
||||||
return 0;
|
return 0;
|
||||||
@ -387,11 +387,13 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
|
|||||||
msg_t msg;
|
msg_t msg;
|
||||||
blob_t identity;
|
blob_t identity;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
bool next_identity_used = false;
|
||||||
|
|
||||||
if (next_identity.length()) {
|
if (next_identity.length()) {
|
||||||
identity = blob_t((unsigned char*) next_identity.c_str(),
|
identity = blob_t((unsigned char*) next_identity.c_str(),
|
||||||
next_identity.length());
|
next_identity.length());
|
||||||
next_identity.clear();
|
next_identity.clear();
|
||||||
|
next_identity_used = true;
|
||||||
}
|
}
|
||||||
else if (options.raw_sock) { // Always assign identity for raw-socket
|
else if (options.raw_sock) { // Always assign identity for raw-socket
|
||||||
unsigned char buf [5];
|
unsigned char buf [5];
|
||||||
@ -399,13 +401,15 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
|
|||||||
put_uint32 (buf + 1, next_peer_id++);
|
put_uint32 (buf + 1, next_peer_id++);
|
||||||
identity = blob_t (buf, sizeof buf);
|
identity = blob_t (buf, sizeof buf);
|
||||||
}
|
}
|
||||||
else {
|
if (!options.raw_sock){ // pick up handshake cases and also case where next identity is set
|
||||||
msg.init ();
|
msg.init ();
|
||||||
ok = pipe_->read (&msg);
|
ok = pipe_->read (&msg);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return false;
|
return false;
|
||||||
|
if (next_identity_used){ // we read but do not use identity from peer
|
||||||
if (msg.size () == 0) {
|
msg.close();
|
||||||
|
}
|
||||||
|
else if (msg.size () == 0) {
|
||||||
// Fall back on the auto-generation
|
// Fall back on the auto-generation
|
||||||
unsigned char buf [5];
|
unsigned char buf [5];
|
||||||
buf [0] = 0;
|
buf [0] = 0;
|
||||||
|
@ -164,7 +164,8 @@ namespace zmq
|
|||||||
|
|
||||||
// Monitor socket cleanup
|
// Monitor socket cleanup
|
||||||
void stop_monitor ();
|
void stop_monitor ();
|
||||||
|
// Next assigned name on a zmq_connect() call used by ROUTER and STREAM socket types
|
||||||
|
std::string next_identity;
|
||||||
private:
|
private:
|
||||||
// Creates new endpoint ID and adds the endpoint to the map.
|
// Creates new endpoint ID and adds the endpoint to the map.
|
||||||
void add_endpoint (const char *addr_, own_t *endpoint_, pipe_t *pipe);
|
void add_endpoint (const char *addr_, own_t *endpoint_, pipe_t *pipe);
|
||||||
|
@ -167,7 +167,7 @@ int zmq::stream_t::xsetsockopt (int option_, const void *optval_,
|
|||||||
size_t optvallen_)
|
size_t optvallen_)
|
||||||
{
|
{
|
||||||
switch (option_) {
|
switch (option_) {
|
||||||
case ZMQ_NEXT_IDENTITY:
|
case ZMQ_NEXT_CONNECT_PEER_ID:
|
||||||
if(optval_ && optvallen_) {
|
if(optval_ && optvallen_) {
|
||||||
next_identity.assign((char*)optval_,optvallen_);
|
next_identity.assign((char*)optval_,optvallen_);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user