@@ -78,11 +78,18 @@ class Connection : public ObjectWrap {
78
78
TRACE (" created class" );
79
79
}
80
80
81
- // static function called by libev as callback entrypoint
81
+ // static function called by libuv as callback entrypoint
82
82
static void
83
83
io_event (uv_poll_t * w, int status, int revents)
84
84
{
85
+
85
86
TRACE (" Received IO event" );
87
+
88
+ if (status == -1 ) {
89
+ LOG (" Connection error." );
90
+ return ;
91
+ }
92
+
86
93
Connection *connection = static_cast <Connection*>(w->data );
87
94
connection->HandleIOEvent (revents);
88
95
}
@@ -294,7 +301,7 @@ class Connection : public ObjectWrap {
294
301
return rv;
295
302
}
296
303
297
- int Cancel ()
304
+ bool Cancel ()
298
305
{
299
306
PGcancel* pgCancel = PQgetCancel (connection_);
300
307
char errbuf[256 ];
@@ -379,30 +386,26 @@ class Connection : public ObjectWrap {
379
386
Emit (" notice" , ¬ice);
380
387
}
381
388
382
- // called to process io_events from libev
389
+ // called to process io_events from libuv
383
390
void HandleIOEvent (int revents)
384
391
{
385
- if (revents & EV_ERROR) {
386
- LOG (" Connection error." );
387
- return ;
388
- }
389
392
390
393
if (connecting_) {
391
394
TRACE (" Processing connecting_ io" );
392
395
HandleConnectionIO ();
393
396
return ;
394
397
}
395
398
396
- if (revents & EV_READ ) {
397
- TRACE (" revents & EV_READ " );
399
+ if (revents & UV_READABLE ) {
400
+ TRACE (" revents & UV_READABLE " );
398
401
if (PQconsumeInput (connection_) == 0 ) {
399
402
End ();
400
403
EmitLastError ();
401
404
LOG (" Something happened, consume input is 0" );
402
405
return ;
403
406
}
404
407
405
- // declare handlescope as this method is entered via a libev callback
408
+ // declare handlescope as this method is entered via a libuv callback
406
409
// and not part of the public v8 interface
407
410
HandleScope scope;
408
411
@@ -432,8 +435,8 @@ class Connection : public ObjectWrap {
432
435
433
436
}
434
437
435
- if (revents & EV_WRITE ) {
436
- TRACE (" revents & EV_WRITE " );
438
+ if (revents & UV_WRITABLE ) {
439
+ TRACE (" revents & UV_WRITABLE " );
437
440
if (PQflush (connection_) == 0 ) {
438
441
StopWrite ();
439
442
}
0 commit comments