mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-23 00:08:02 +02:00
Merge pull request #2921 from sigiesec/mechanism-cleanup
Problem: code style issues in mechanism_t and socket_base_t
This commit is contained in:
@@ -1033,13 +1033,15 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
|
||||
return -1;
|
||||
}
|
||||
|
||||
const std::string addr_str = std::string (addr_);
|
||||
|
||||
// Disconnect an inproc socket
|
||||
if (protocol == "inproc") {
|
||||
if (unregister_endpoint (std::string (addr_), this) == 0) {
|
||||
if (unregister_endpoint (addr_str, this) == 0) {
|
||||
return 0;
|
||||
}
|
||||
std::pair<inprocs_t::iterator, inprocs_t::iterator> range =
|
||||
inprocs.equal_range (std::string (addr_));
|
||||
inprocs.equal_range (addr_str);
|
||||
if (range.first == range.second) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
@@ -1051,8 +1053,7 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string resolved_addr = std::string (addr_);
|
||||
std::pair<endpoints_t::iterator, endpoints_t::iterator> range;
|
||||
std::string resolved_addr = addr_;
|
||||
|
||||
// The resolved last_endpoint is used as a key in the endpoints map.
|
||||
// The address passed by the user might not match in the TCP case due to
|
||||
@@ -1060,17 +1061,14 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
|
||||
// resolve before giving up. Given at this stage we don't know whether a
|
||||
// socket is connected or bound, try with both.
|
||||
if (protocol == "tcp") {
|
||||
range = endpoints.equal_range (resolved_addr);
|
||||
if (range.first == range.second) {
|
||||
if (endpoints.find (resolved_addr) == endpoints.end ()) {
|
||||
tcp_address_t *tcp_addr = new (std::nothrow) tcp_address_t ();
|
||||
alloc_assert (tcp_addr);
|
||||
rc = tcp_addr->resolve (address.c_str (), false, options.ipv6);
|
||||
|
||||
if (rc == 0) {
|
||||
tcp_addr->to_string (resolved_addr);
|
||||
range = endpoints.equal_range (resolved_addr);
|
||||
|
||||
if (range.first == range.second) {
|
||||
if (endpoints.find (resolved_addr) == endpoints.end ()) {
|
||||
rc =
|
||||
tcp_addr->resolve (address.c_str (), true, options.ipv6);
|
||||
if (rc == 0) {
|
||||
@@ -1083,7 +1081,8 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
|
||||
}
|
||||
|
||||
// Find the endpoints range (if any) corresponding to the addr_ string.
|
||||
range = endpoints.equal_range (resolved_addr);
|
||||
const std::pair<endpoints_t::iterator, endpoints_t::iterator> range =
|
||||
endpoints.equal_range (resolved_addr);
|
||||
if (range.first == range.second) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user