Merge pull request #196 from booo/uv_events

windows build
This commit is contained in:
Brian C 2012-10-10 07:40:01 -07:00
commit d715515f94
2 changed files with 36 additions and 14 deletions

View File

@ -5,8 +5,27 @@
'sources': [
'src/binding.cc'
],
'include_dirs': ['<!@(pg_config --includedir)'],
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
'conditions' : [
['OS=="mac"', {
'include_dirs': ['<!@(pg_config --includedir)'],
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
}],
['OS=="linux"', {
'include_dirs': ['<!@(pg_config --includedir)'],
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
}],
['OS=="win"', {
'include_dirs': ['<!@(pg_config --includedir)'],
'libraries' : ['libpq.lib'],
'msvs_settings': {
'VCLinkerTool' : {
'AdditionalLibraryDirectories' : [
'<!@(pg_config --libdir)\\'
]
},
}
}]
]
}
]
}

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);
}
@ -294,7 +301,7 @@ protected:
return rv;
}
int Cancel()
bool Cancel()
{
PGcancel* pgCancel = PQgetCancel(connection_);
char errbuf[256];
@ -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();
}