As its used now for more than just suspending, the old does not fit anymore.
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
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;
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);
}
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;