From 175d18dce745f17ea148f8f9687859485c7bdc51 Mon Sep 17 00:00:00 2001 From: booo Date: Fri, 3 Aug 2012 03:25:11 +0200 Subject: [PATCH 1/4] Fix for issue #165. Use libuv events instead of libev events. --- src/binding.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/binding.cc b/src/binding.cc index e4a31bb7..b94c25aa 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -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(w->data); connection->HandleIOEvent(revents); } @@ -379,13 +386,9 @@ protected: Emit("notice", ¬ice); } - //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(); } From 7826e492b49e071e5bb7816e2a7b365b2832d036 Mon Sep 17 00:00:00 2001 From: booo Date: Fri, 3 Aug 2012 03:32:30 +0200 Subject: [PATCH 2/4] Change return type of Cancel() to bool. This should fix the following warning on windows: ..\src\binding.cc(117): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) Spotted in issue #165. --- src/binding.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding.cc b/src/binding.cc index b94c25aa..eb927bf9 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -301,7 +301,7 @@ protected: return rv; } - int Cancel() + bool Cancel() { PGcancel* pgCancel = PQgetCancel(connection_); char errbuf[256]; From 4cb66d1a94852748358653169ea25ea0d65272c7 Mon Sep 17 00:00:00 2001 From: booo Date: Wed, 19 Sep 2012 19:44:25 +0200 Subject: [PATCH 3/4] Add conditions to the binding.gyp for windows, linux, mac. --- binding.gyp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index cdb78e0a..1e145416 100644 --- a/binding.gyp +++ b/binding.gyp @@ -5,8 +5,27 @@ 'sources': [ 'src/binding.cc' ], - 'include_dirs': [' Date: Wed, 26 Sep 2012 09:36:23 +0200 Subject: [PATCH 4/4] Change library extension for windows build. Thanks to image72! --- binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index 1e145416..d89faaea 100644 --- a/binding.gyp +++ b/binding.gyp @@ -16,7 +16,7 @@ }], ['OS=="win"', { 'include_dirs': ['