mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-05 20:57:40 +01:00
Problem: stream listeners do not provide correct local and remote address information (test_monitor is failing)
Solution: query local and remote addresses on accepting a connection
This commit is contained in:
@@ -152,9 +152,11 @@ void zmq::ipc_listener_t::in_event ()
|
|||||||
create_engine (fd);
|
create_engine (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zmq::ipc_listener_t::get_local_socket_name (zmq::fd_t fd_) const
|
std::string
|
||||||
|
zmq::ipc_listener_t::get_socket_name (zmq::fd_t fd_,
|
||||||
|
socket_end_t socket_end_) const
|
||||||
{
|
{
|
||||||
return zmq::get_socket_name<ipc_address_t> (fd_, socket_end_local);
|
return zmq::get_socket_name<ipc_address_t> (fd_, socket_end_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::ipc_listener_t::set_local_address (const char *addr_)
|
int zmq::ipc_listener_t::set_local_address (const char *addr_)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class ipc_listener_t : public stream_listener_base_t
|
|||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_local_socket_name (fd_t fd_) const;
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ zmq::stream_listener_base_t::~stream_listener_base_t ()
|
|||||||
|
|
||||||
int zmq::stream_listener_base_t::get_local_address (std::string &addr_) const
|
int zmq::stream_listener_base_t::get_local_address (std::string &addr_) const
|
||||||
{
|
{
|
||||||
addr_ = get_local_socket_name (_s);
|
addr_ = get_socket_name (_s, socket_end_local);
|
||||||
return addr_.empty () ? -1 : 0;
|
return addr_.empty () ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,8 @@ int zmq::stream_listener_base_t::close ()
|
|||||||
void zmq::stream_listener_base_t::create_engine (fd_t fd)
|
void zmq::stream_listener_base_t::create_engine (fd_t fd)
|
||||||
{
|
{
|
||||||
const endpoint_uri_pair_t endpoint_pair (
|
const endpoint_uri_pair_t endpoint_pair (
|
||||||
_endpoint, get_local_socket_name (fd), endpoint_type_bind);
|
get_socket_name (fd, socket_end_local),
|
||||||
|
get_socket_name (fd, socket_end_remote), endpoint_type_bind);
|
||||||
|
|
||||||
stream_engine_t *engine =
|
stream_engine_t *engine =
|
||||||
new (std::nothrow) stream_engine_t (fd, options, endpoint_pair);
|
new (std::nothrow) stream_engine_t (fd, options, endpoint_pair);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "own.hpp"
|
#include "own.hpp"
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
#include "io_object.hpp"
|
#include "io_object.hpp"
|
||||||
#include "tipc_address.hpp"
|
#include "address.hpp"
|
||||||
|
|
||||||
namespace zmq
|
namespace zmq
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,8 @@ class stream_listener_base_t : public own_t, public io_object_t
|
|||||||
int get_local_address (std::string &addr_) const;
|
int get_local_address (std::string &addr_) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::string get_local_socket_name (fd_t fd_) const = 0;
|
virtual std::string get_socket_name (fd_t fd_,
|
||||||
|
socket_end_t socket_end_) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for incoming commands.
|
// Handlers for incoming commands.
|
||||||
|
|||||||
@@ -94,9 +94,11 @@ void zmq::tcp_listener_t::in_event ()
|
|||||||
create_engine (fd);
|
create_engine (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zmq::tcp_listener_t::get_local_socket_name (zmq::fd_t fd_) const
|
std::string
|
||||||
|
zmq::tcp_listener_t::get_socket_name (zmq::fd_t fd_,
|
||||||
|
socket_end_t socket_end_) const
|
||||||
{
|
{
|
||||||
return zmq::get_socket_name<tcp_address_t> (fd_, socket_end_local);
|
return zmq::get_socket_name<tcp_address_t> (fd_, socket_end_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_listener_t::set_local_address (const char *addr_)
|
int zmq::tcp_listener_t::set_local_address (const char *addr_)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class tcp_listener_t : public stream_listener_base_t
|
|||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_local_socket_name (fd_t fd_) const;
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
|
|||||||
@@ -78,9 +78,11 @@ void zmq::tipc_listener_t::in_event ()
|
|||||||
create_engine (fd);
|
create_engine (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zmq::tipc_listener_t::get_local_socket_name (zmq::fd_t fd_) const
|
std::string
|
||||||
|
zmq::tipc_listener_t::get_socket_name (zmq::fd_t fd_,
|
||||||
|
socket_end_t socket_end_) const
|
||||||
{
|
{
|
||||||
return zmq::get_socket_name<tipc_address_t> (fd_, socket_end_local);
|
return zmq::get_socket_name<tipc_address_t> (fd_, socket_end_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tipc_listener_t::set_local_address (const char *addr_)
|
int zmq::tipc_listener_t::set_local_address (const char *addr_)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class tipc_listener_t : public stream_listener_base_t
|
|||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_local_socket_name (fd_t fd_) const;
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
|
|||||||
Reference in New Issue
Block a user