From: Marko Kreen Date: Thu, 2 Aug 2007 11:56:28 +0000 (+0000) Subject: avoid recv() if buffer has data X-Git-Tag: pgbouncer_1_1~66 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e60d6ab661facc5f1cd16b79b75f553605f2e54;p=pgbouncer avoid recv() if buffer has data --- diff --git a/src/sbuf.c b/src/sbuf.c index a08a60c..40eb41a 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -175,11 +175,19 @@ void sbuf_pause(SBuf *sbuf) /* resume from pause, start waiting for data */ void sbuf_continue(SBuf *sbuf) { + bool do_recv = true; AssertActive(sbuf); sbuf_wait_for_data(sbuf); - /* FIXME: > SMALL_PKT in buffer, skip the recv() ?? */ + /* + * FIXME: is it safe? + * + * if avail > SMALL_PKT in buffer, skip the recv(). + */ + if (sbuf->recv_pos - sbuf->pkt_pos >= SMALL_PKT) + do_recv = false; + /* * There may be some data already received, * but not certain, so avoid SKIP_RECV.