diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-11-20 20:48:26 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-11-20 20:48:26 +0000 |
commit | dc8f337a59f4b8ce07101259d9644771b738892e (patch) | |
tree | b40256e024c0e715f789269c30527b9698bb35ea /src/libserver/rspamd_control.c | |
parent | 1458ebf995bd59458ef35b9788235bac54b5f31f (diff) | |
download | rspamd-dc8f337a59f4b8ce07101259d9644771b738892e.tar.gz rspamd-dc8f337a59f4b8ce07101259d9644771b738892e.zip |
[Minor] Add some more logs to the erros in the control path
Diffstat (limited to 'src/libserver/rspamd_control.c')
-rw-r--r-- | src/libserver/rspamd_control.c | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index 63999ab6f..21a8c495e 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -928,8 +928,8 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents) ev_io_stop (EV_A_ w); } else if (r != sizeof (cmd)) { - msg_err ("cannot read from worker's srv pipe incomplete command: %d", - (gint) r); + msg_err ("cannot read from worker's srv pipe incomplete command: %d != %d; command = %s", + (gint)r, sizeof(cmd), rspamd_srv_command_to_string(cmd.type)); } else { rdata = g_malloc0 (sizeof (*rdata)); @@ -1069,8 +1069,13 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents) r = sendmsg (w->fd, &msg, 0); if (r == -1) { - msg_err ("cannot write to worker's srv pipe: %s", - strerror (errno)); + msg_err ("cannot write to worker's srv pipe when writing reply: %s; command = %s", + strerror (errno), rspamd_srv_command_to_string(rdata->rep.type)); + } + else if (r != sizeof (rdata->rep)) { + msg_err ("cannot write to worker's srv pipe: %d != %d; command = %s", + (int)r, (int)sizeof (rdata->rep), + rspamd_srv_command_to_string(rdata->rep.type)); } g_free (rdata); @@ -1139,7 +1144,13 @@ rspamd_srv_request_handler (EV_P_ ev_io *w, int revents) r = sendmsg (w->fd, &msg, 0); if (r == -1) { - msg_err ("cannot write to server pipe: %s", strerror (errno)); + msg_err ("cannot write to server pipe: %s; command = %s", strerror (errno), + rspamd_srv_command_to_string(rd->cmd.type)); + goto cleanup; + } + else if (r != sizeof (rd->cmd)) { + msg_err("incomplete write to the server pipe: %d != %d, command = %s", + (int)r, (int)sizeof(rd->cmd), rspamd_srv_command_to_string(rd->cmd.type)); goto cleanup; } @@ -1159,13 +1170,14 @@ rspamd_srv_request_handler (EV_P_ ev_io *w, int revents) r = recvmsg (w->fd, &msg, 0); if (r == -1) { - msg_err ("cannot read from server pipe: %s", strerror (errno)); + msg_err ("cannot read from server pipe: %s; command = %s", strerror (errno), + rspamd_srv_command_to_string(rd->cmd.type)); goto cleanup; } - if (r < (gint)sizeof (rd->rep)) { - msg_err ("cannot read from server pipe, invalid length: %d", - (gint)r); + if (r != (gint)sizeof (rd->rep)) { + msg_err ("cannot read from server pipe, invalid length: %d != %d; command = %s", + (gint)r, (int)sizeof (rd->rep), rspamd_srv_command_to_string(rd->cmd.type)); goto cleanup; } @@ -1302,3 +1314,37 @@ rspamd_control_command_to_string (enum rspamd_control_type cmd) return reply; } + +const gchar *rspamd_srv_command_to_string (enum rspamd_srv_type cmd) +{ + const gchar *reply = "unknown"; + + switch (cmd) { + case RSPAMD_SRV_SOCKETPAIR: + reply = "socketpair"; + break; + case RSPAMD_SRV_HYPERSCAN_LOADED: + reply = "hyperscan_loaded"; + break; + case RSPAMD_SRV_MONITORED_CHANGE: + reply = "monitored_change"; + break; + case RSPAMD_SRV_LOG_PIPE: + reply = "log_pipe"; + break; + case RSPAMD_SRV_ON_FORK: + reply = "on_fork"; + break; + case RSPAMD_SRV_HEARTBEAT: + reply = "heartbeat"; + break; + case RSPAMD_SRV_HEALTH: + reply = "health"; + break; + case RSPAMD_NOTICE_HYPERSCAN_CACHE: + reply = "notice_hyperscan_cache"; + break; + } + + return reply; +} |