Fix for issue #165. Use libuv events instead of libev events.

This commit is contained in:
booo 2012-08-03 03:25:11 +02:00
parent 9341efe669
commit 175d18dce7

View File

@ -78,11 +78,18 @@ public:
TRACE("created class");
}
//static function called by libev as callback entrypoint
//static function called by libuv as callback entrypoint
static void
io_event(uv_poll_t* w, int status, int revents)
{
TRACE("Received IO event");
if(status == -1) {
LOG("Connection error.");
return;
}
Connection *connection = static_cast<Connection*>(w->data);
connection->HandleIOEvent(revents);
}
@ -379,13 +386,9 @@ protected:
Emit("notice", &notice);
}
//called to process io_events from libev
//called to process io_events from libuv
void HandleIOEvent(int revents)
{
if(revents & EV_ERROR) {
LOG("Connection error.");
return;
}
if(connecting_) {
TRACE("Processing connecting_ io");
@ -393,8 +396,8 @@ protected:
return;
}
if(revents & EV_READ) {
TRACE("revents & EV_READ");
if(revents & UV_READABLE) {
TRACE("revents & UV_READABLE");
if(PQconsumeInput(connection_) == 0) {
End();
EmitLastError();
@ -402,7 +405,7 @@ protected:
return;
}
//declare handlescope as this method is entered via a libev callback
//declare handlescope as this method is entered via a libuv callback
//and not part of the public v8 interface
HandleScope scope;
@ -432,8 +435,8 @@ protected:
}
if(revents & EV_WRITE) {
TRACE("revents & EV_WRITE");
if(revents & UV_WRITABLE) {
TRACE("revents & UV_WRITABLE");
if (PQflush(connection_) == 0) {
StopWrite();
}