return true;
}
+static void full_resume(void)
+{
+ int tmp_mode = cf_pause_mode;
+ cf_pause_mode = P_NONE;
+ if (tmp_mode == P_SUSPEND)
+ resume_all();
+}
+
/* Command: RESUME */
static bool admin_cmd_resume(PgSocket *admin, const char *arg)
{
return admin_error(admin, "admin access needed");
if (!arg[0]) {
- int tmp_mode = cf_pause_mode;
log_info("RESUME command issued");
- cf_pause_mode = P_NONE;
- switch (tmp_mode) {
- case P_SUSPEND:
- resume_all();
- case P_PAUSE:
- break;
- default:
+ if (cf_pause_mode != P_NONE)
+ full_resume();
+ else
return admin_error(admin, "Pooler is not paused/suspended");
- }
} else {
PgDatabase *db = find_database(arg);
log_info("PAUSE '%s' command issued", arg);
}
}
+/* admin on console has pressed ^C */
+void admin_handle_cancel(PgSocket *admin)
+{
+ bool res;
+
+ /* weird, but no reason to fail */
+ if (!admin->wait_for_response)
+ slog_warning(admin, "admin cancel request for non-waiting client?");
+
+ if (cf_pause_mode != P_NONE)
+ full_resume();
+
+ /* notify readiness */
+ SEND_ReadyForQuery(res, admin);
+ if (!res)
+ disconnect_client(admin, false, "readiness send failed");
+}
+
void admin_pause_done(void);
void admin_flush(PgSocket *admin, PktBuf *buf, const char *desc);
bool admin_ready(PgSocket *admin, const char *desc);
+void admin_handle_cancel(PgSocket *client);
+
/* not linked client, just drop it then */
if (!main_client->link) {
- disconnect_client(main_client, true, "canceling idle client");
+ bool res;
disconnect_client(req, false, "cancel req for idle client");
+
+ /* let administrative cancel be handled elsewhere */
+ if (main_client->pool->admin) {
+ admin_handle_cancel(main_client);
+ return;
+ }
+
+ /* notify readiness */
+ SEND_ReadyForQuery(res, main_client);
+ if (!res)
+ disconnect_client(main_client, true,
+ "ReadyForQuery for main_client failed");
return;
}