From 57e6fd0e0e8d93f5e1e062d387110067528d6f9a Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Thu, 15 Mar 2007 14:48:48 +0000 Subject: [PATCH] immidiate suspend of logged in clients should be done bit differently --- src/janitor.c | 21 ++++++++++++++------- src/janitor.h | 1 + src/objects.c | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/janitor.c b/src/janitor.c index 57d2d8d..2840397 100644 --- a/src/janitor.c +++ b/src/janitor.c @@ -37,6 +37,18 @@ 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)) { + sbuf_pause(&sk->sbuf); + sk->suspended = 1; + } else + return false; + } + return true; +} + /* suspend all sockets in socket list */ static int suspend_socket_list(StatList *list) { @@ -46,13 +58,8 @@ static int suspend_socket_list(StatList *list) statlist_for_each(item, list) { sk = container_of(item, PgSocket, head); - if (!sk->suspended) { - if (sbuf_has_no_state(&sk->sbuf)) { - sbuf_pause(&sk->sbuf); - sk->suspended = 1; - } else - active++; - } + if (!suspend_socket(sk)) + active++; } return active; } diff --git a/src/janitor.h b/src/janitor.h index 2c8ccd1..e37c6e1 100644 --- a/src/janitor.h +++ b/src/janitor.h @@ -20,4 +20,5 @@ void janitor_setup(void); void config_postprocess(void); void resume_all(void); void per_loop_object_maint(void); +bool suspend_socket(PgSocket *sk); diff --git a/src/objects.c b/src/objects.c index 7222af3..e5e857f 100644 --- a/src/objects.c +++ b/src/objects.c @@ -758,7 +758,7 @@ bool finish_client_login(PgSocket *client) /* in suspend, dont let send query */ if (cf_pause_mode == P_SUSPEND) - pause_client(client); + suspend_socket(client); return true; } -- 2.40.0