Update libuv.h

- if status is not ok, report that as readable
- no need to stop uv_poll_t before changing events according to the docs
This commit is contained in:
David Nikdel 2016-07-16 20:27:00 -04:00 committed by GitHub
parent b8d2c0c600
commit 1e1ec0c133
1 changed files with 5 additions and 6 deletions

View File

@ -64,7 +64,7 @@ private:
// tell the connection that its filedescriptor is active // tell the connection that its filedescriptor is active
int fd = -1; int fd = -1;
uv_fileno(reinterpret_cast<uv_handle_t*>(handle), &fd); uv_fileno(reinterpret_cast<uv_handle_t*>(handle), &fd);
connection->process(fd, uv_to_amqp_events(events)); connection->process(fd, uv_to_amqp_events(status, events));
} }
public: public:
@ -119,10 +119,7 @@ private:
*/ */
void events(int events) void events(int events)
{ {
// stop the watcher if it was active // update the events being watched for
uv_poll_stop(_poll);
// and restart it
uv_poll_start(_poll, amqp_to_uv_events(events), callback); uv_poll_start(_poll, amqp_to_uv_events(events), callback);
} }
@ -131,13 +128,15 @@ private:
/** /**
* Convert event flags from UV format to AMQP format * Convert event flags from UV format to AMQP format
*/ */
static int uv_to_amqp_events(int events) static int uv_to_amqp_events(int status, int events)
{ {
int amqp_events = 0; int amqp_events = 0;
if (events & UV_READABLE) if (events & UV_READABLE)
amqp_events |= AMQP::readable; amqp_events |= AMQP::readable;
if (events & UV_WRITABLE) if (events & UV_WRITABLE)
amqp_events |= AMQP::writable; amqp_events |= AMQP::writable;
if (status != 0)
amqp_events |= AMQP::readable;
return amqp_events; return amqp_events;
} }