Skip to content

Commit 300e70c

Browse files
committed
Merge pull request brianc#388 from brianc/issues/320
Issues/320
2 parents 5806afc + 7518149 commit 300e70c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/binding.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <stdlib.h>
77

88
#define LOG(msg) printf("%s\n",msg);
9-
#define TRACE(msg) //printf(%s\n, msg);
9+
#define TRACE(msg) //printf("%s\n", msg);
1010

1111

1212
#define THROW(msg) return ThrowException(Exception::Error(String::New(msg)));
@@ -251,6 +251,7 @@ class Connection : public ObjectWrap {
251251
bool copyInMode_;
252252
bool reading_;
253253
bool writing_;
254+
bool ended_;
254255
Connection () : ObjectWrap ()
255256
{
256257
connection_ = NULL;
@@ -260,6 +261,7 @@ class Connection : public ObjectWrap {
260261
copyInMode_ = false;
261262
reading_ = false;
262263
writing_ = false;
264+
ended_ = false;
263265
TRACE("Initializing ev watchers");
264266
read_watcher_.data = this;
265267
write_watcher_.data = this;
@@ -369,6 +371,7 @@ class Connection : public ObjectWrap {
369371
//and hands off control to libev
370372
bool Connect(const char* conninfo)
371373
{
374+
if(ended_) return true;
372375
connection_ = PQconnectStart(conninfo);
373376

374377
if (!connection_) {
@@ -660,6 +663,7 @@ class Connection : public ObjectWrap {
660663
StopWrite();
661664
DestroyConnection();
662665
Emit("_end");
666+
ended_ = true;
663667
}
664668

665669
private:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//test for issue #320
2+
//
3+
var helper = require('./test-helper');
4+
5+
var client = new helper.pg.Client(helper.config);
6+
client.connect();
7+
client.end();

0 commit comments

Comments
 (0)