@@ -78,11 +78,18 @@ class Connection : public ObjectWrap {
7878 TRACE (" created class" );
7979 }
8080
81- // static function called by libev as callback entrypoint
81+ // static function called by libuv as callback entrypoint
8282 static void
8383 io_event (uv_poll_t * w, int status, int revents)
8484 {
85+
8586 TRACE (" Received IO event" );
87+
88+ if (status == -1 ) {
89+ LOG (" Connection error." );
90+ return ;
91+ }
92+
8693 Connection *connection = static_cast <Connection*>(w->data );
8794 connection->HandleIOEvent (revents);
8895 }
@@ -294,7 +301,7 @@ class Connection : public ObjectWrap {
294301 return rv;
295302 }
296303
297- int Cancel ()
304+ bool Cancel ()
298305 {
299306 PGcancel* pgCancel = PQgetCancel (connection_);
300307 char errbuf[256 ];
@@ -379,30 +386,26 @@ class Connection : public ObjectWrap {
379386 Emit (" notice" , ¬ice);
380387 }
381388
382- // called to process io_events from libev
389+ // called to process io_events from libuv
383390 void HandleIOEvent (int revents)
384391 {
385- if (revents & EV_ERROR) {
386- LOG (" Connection error." );
387- return ;
388- }
389392
390393 if (connecting_) {
391394 TRACE (" Processing connecting_ io" );
392395 HandleConnectionIO ();
393396 return ;
394397 }
395398
396- if (revents & EV_READ ) {
397- TRACE (" revents & EV_READ " );
399+ if (revents & UV_READABLE ) {
400+ TRACE (" revents & UV_READABLE " );
398401 if (PQconsumeInput (connection_) == 0 ) {
399402 End ();
400403 EmitLastError ();
401404 LOG (" Something happened, consume input is 0" );
402405 return ;
403406 }
404407
405- // declare handlescope as this method is entered via a libev callback
408+ // declare handlescope as this method is entered via a libuv callback
406409 // and not part of the public v8 interface
407410 HandleScope scope;
408411
@@ -432,8 +435,8 @@ class Connection : public ObjectWrap {
432435
433436 }
434437
435- if (revents & EV_WRITE ) {
436- TRACE (" revents & EV_WRITE " );
438+ if (revents & UV_WRITABLE ) {
439+ TRACE (" revents & UV_WRITABLE " );
437440 if (PQflush (connection_) == 0 ) {
438441 StopWrite ();
439442 }
0 commit comments