From: Marko Kreen Date: Wed, 28 Mar 2007 09:21:26 +0000 (+0000) Subject: Rename sbuf_has_no_state() to sbuf_is_empty() X-Git-Tag: pgbouncer_1_0_2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9507c5d678f54593f46498c6eb2e8a399e24f76e;p=pgbouncer Rename sbuf_has_no_state() to sbuf_is_empty() As its used now for more than just suspending, the old does not fit anymore. --- diff --git a/src/janitor.c b/src/janitor.c index 0278a52..0a64503 100644 --- a/src/janitor.c +++ b/src/janitor.c @@ -40,7 +40,7 @@ static void close_server_list(StatList *sk_list, const char *reason) bool suspend_socket(PgSocket *sk) { if (!sk->suspended) { - if (sbuf_has_no_state(&sk->sbuf)) { + if (sbuf_is_empty(&sk->sbuf)) { sbuf_pause(&sk->sbuf); sk->suspended = 1; } else diff --git a/src/objects.c b/src/objects.c index 69b4a28..d17cf93 100644 --- a/src/objects.c +++ b/src/objects.c @@ -641,7 +641,7 @@ void disconnect_client(PgSocket *client, bool notify, const char *reason) if (client->link) { PgSocket *server = client->link; /* ->ready may be set before all is sent */ - if (server->ready && sbuf_has_no_state(&server->sbuf)) { + if (server->ready && sbuf_is_empty(&server->sbuf)) { release_server(server); } else { server->link = NULL; diff --git a/src/sbuf.c b/src/sbuf.c index 223005c..74c319d 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -468,7 +468,7 @@ try_more: sbuf_try_resync(sbuf); /* notify proto that all is sent */ - if (sbuf_has_no_state(sbuf)) + if (sbuf_is_empty(sbuf)) sbuf_call_proto(sbuf, SBUF_EV_FLUSH); } diff --git a/src/sbuf.h b/src/sbuf.h index 615765e..bb39382 100644 --- a/src/sbuf.h +++ b/src/sbuf.h @@ -84,8 +84,11 @@ bool sbuf_answer(SBuf *sbuf, const void *buf, int len); void sbuf_continue_with_callback(SBuf *sbuf, sbuf_libevent_cb cb); -/* returns true if SBuf is suspendable */ -static inline bool sbuf_has_no_state(SBuf *sbuf) +/* + * Returns true if SBuf is has no data buffered + * and is not in a middle of a packet. + */ +static inline bool sbuf_is_empty(SBuf *sbuf) { return sbuf->send_pos == sbuf->recv_pos && sbuf->pkt_remain == 0;