Commit aef2171e authored by Martin Hurton's avatar Martin Hurton

Make last_endpoint attribute of socket object

parent fd7e9b8c
......@@ -501,14 +501,6 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
}
break;
case ZMQ_LAST_ENDPOINT:
if (*optvallen_ >= last_endpoint.size () + 1) {
memcpy (optval_, last_endpoint.c_str (), last_endpoint.size () + 1);
*optvallen_ = last_endpoint.size () + 1;
return 0;
}
break;
case ZMQ_MECHANISM:
if (is_int) {
*value = mechanism;
......
......@@ -50,9 +50,6 @@ namespace zmq
unsigned char identity_size;
unsigned char identity [256];
// Last socket endpoint resolved URI
std::string last_endpoint;
// Maximum tranfer rate [kb/s]. Default 100kb/s.
int rate;
......
......@@ -302,6 +302,16 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
return 0;
}
if (option_ == ZMQ_LAST_ENDPOINT) {
if (*optvallen_ < last_endpoint.size () + 1) {
errno = EINVAL;
return -1;
}
strcpy (static_cast <char *> (optval_), last_endpoint.c_str ());
*optvallen_ = last_endpoint.size () + 1;
return 0;
}
return options.getsockopt (option_, optval_, optvallen_);
}
......@@ -333,7 +343,7 @@ int zmq::socket_base_t::bind (const char *addr_)
int rc = register_endpoint (addr_, endpoint);
if (rc == 0) {
// Save last endpoint URI
options.last_endpoint.assign (addr_);
last_endpoint.assign (addr_);
}
return rc;
}
......@@ -364,7 +374,7 @@ int zmq::socket_base_t::bind (const char *addr_)
}
// Save last endpoint URI
listener->get_address (options.last_endpoint);
listener->get_address (last_endpoint);
add_endpoint (addr_, (own_t *) listener);
return 0;
......@@ -383,7 +393,7 @@ int zmq::socket_base_t::bind (const char *addr_)
}
// Save last endpoint URI
listener->get_address (options.last_endpoint);
listener->get_address (last_endpoint);
add_endpoint (addr_, (own_t *) listener);
return 0;
......@@ -478,7 +488,7 @@ int zmq::socket_base_t::connect (const char *addr_)
send_bind (peer.socket, new_pipes [1], false);
// Save last endpoint URI
options.last_endpoint.assign (addr_);
last_endpoint.assign (addr_);
// remember inproc connections for disconnect
inprocs.insert (inprocs_t::value_type (std::string (addr_), new_pipes[0]));
......@@ -556,7 +566,7 @@ int zmq::socket_base_t::connect (const char *addr_)
}
// Save last endpoint URI
paddr->to_string (options.last_endpoint);
paddr->to_string (last_endpoint);
add_endpoint (addr_, (own_t *) session);
return 0;
......
......@@ -238,6 +238,9 @@ namespace zmq
// Bitmask of events being monitored
int monitor_events;
// Last socket endpoint resolved URI
std::string last_endpoint;
socket_base_t (const socket_base_t&);
const socket_base_t &operator = (const socket_base_t&);
mutex_t sync;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment