Possible typo in PollingZMQContext::registerSocket()
MasterAler opened this issue · 1 comments
Greetings!
I'm trying nzmqt on Ubuntu 16.04 LTS (gcc 5.4.0) with Qt 5.5.1 (default). ZeroMQ was installed from libzmq3-dev. These are not important details, mentioning it just to be on the safe side.
Everything works well with cppzmq included, but I've noticed the following (impl.hpp):
NZMQT_INLINE void PollingZMQContext::registerSocket(ZMQSocket* socket_)
{
pollitem_t pollItem = { *socket_, 0, ZMQSocket::EVT_POLLIN, 0 };
QMutexLocker lock(&m_pollItemsMutex);
m_pollItems.push_back(pollItem);
super::registerSocket(socket_);
}
That struct, pollitem_t
is defined in zmq.h as follows:
typedef struct zmq_pollitem_t
{
void *socket;
#if defined _WIN32
SOCKET fd;
#else
int fd;
#endif
short events;
short revents;
} zmq_pollitem_t;
I'm a C++ programmer, not so very good with pure C and it's kinky options, but doesn't that mean assigning a dereferenced pointer (socket) to the void*
field of the structure? Perhaps, dereferencing is not required there?
Like... pollitem_t pollItem = { socket_, 0, ZMQSocket::EVT_POLLIN, 0 };
It never causes any compilation problems, al least with cppzmq included, but looks suspicious a bit.
It's right as is, the ZMQSOcket class defines an operator void *()
, i.e. a conversion to void pointer, which returns the underlying zmq socket handle. That allows you to use the socket directly inside the C api functions as they've done here.