Skip to content

Commit d715515

Browse files
author
Brian C
committed
Merge pull request brianc#196 from booo/uv_events
windows build
2 parents fc91f36 + e4c8d95 commit d715515

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

binding.gyp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,27 @@
55
'sources': [
66
'src/binding.cc'
77
],
8-
'include_dirs': ['<!@(pg_config --includedir)'],
9-
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
8+
'conditions' : [
9+
['OS=="mac"', {
10+
'include_dirs': ['<!@(pg_config --includedir)'],
11+
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
12+
}],
13+
['OS=="linux"', {
14+
'include_dirs': ['<!@(pg_config --includedir)'],
15+
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
16+
}],
17+
['OS=="win"', {
18+
'include_dirs': ['<!@(pg_config --includedir)'],
19+
'libraries' : ['libpq.lib'],
20+
'msvs_settings': {
21+
'VCLinkerTool' : {
22+
'AdditionalLibraryDirectories' : [
23+
'<!@(pg_config --libdir)\\'
24+
]
25+
},
26+
}
27+
}]
28+
]
1029
}
1130
]
1231
}

src/binding.cc

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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", &notice);
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

Comments
 (0)