Skip to content

Commit 0b34675

Browse files
committed
Flush writes to server after every send.
1 parent 6bea039 commit 0b34675

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/binding.cc

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,31 +266,40 @@ class Connection : public ObjectWrap {
266266

267267
int Send(const char *queryText)
268268
{
269-
return PQsendQuery(connection_, queryText);
269+
int rv = PQsendQuery(connection_, queryText);
270+
StartWrite();
271+
return rv;
270272
}
271273

272274
int SendQueryParams(const char *command, const int nParams, const char * const *paramValues)
273275
{
274-
return PQsendQueryParams(connection_, command, nParams, NULL, paramValues, NULL, NULL, 0);
276+
int rv = PQsendQueryParams(connection_, command, nParams, NULL, paramValues, NULL, NULL, 0);
277+
StartWrite();
278+
return rv;
275279
}
276280

277281
int SendPrepare(const char *name, const char *command, const int nParams)
278282
{
279-
return PQsendPrepare(connection_, name, command, nParams, NULL);
283+
int rv = PQsendPrepare(connection_, name, command, nParams, NULL);
284+
StartWrite();
285+
return rv;
280286
}
281287

282288
int SendPreparedQuery(const char *name, int nParams, const char * const *paramValues)
283289
{
284-
return PQsendQueryPrepared(connection_, name, nParams, paramValues, NULL, NULL, 0);
290+
int rv = PQsendQueryPrepared(connection_, name, nParams, paramValues, NULL, NULL, 0);
291+
StartWrite();
292+
return rv;
285293
}
286294

287295
int Cancel()
288296
{
289-
PGcancel* pgCancel = PQgetCancel(connection_);
290-
char errbuf[256];
291-
int result = PQcancel(pgCancel, errbuf, 256);
292-
PQfreeCancel(pgCancel);
293-
return result;
297+
PGcancel* pgCancel = PQgetCancel(connection_);
298+
char errbuf[256];
299+
int result = PQcancel(pgCancel, errbuf, 256);
300+
StartWrite();
301+
PQfreeCancel(pgCancel);
302+
return result;
294303
}
295304

296305
//flushes socket

0 commit comments

Comments
 (0)