From dce2643e5716f082847a90e409c2156dde9e4852 Mon Sep 17 00:00:00 2001 From: Bogdan-Andrei Iancu Date: Fri, 5 Nov 2021 16:34:28 +0200 Subject: [PATCH] [core] improve logging when IPC blocking is detected Throw a CRITical log with info on the target process --- ipc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ipc.c b/ipc.c index c6c30f3f877..05869da40ef 100644 --- a/ipc.c +++ b/ipc.c @@ -180,7 +180,7 @@ ipc_handler_type ipc_register_handler( ipc_handler_f *hdl, char *name) } -static inline int __ipc_send_job(int fd, ipc_handler_type type, +static inline int __ipc_send_job(int fd, int dst_proc, ipc_handler_type type, void *payload1, void *payload2) { ipc_job job; @@ -202,10 +202,16 @@ static inline int __ipc_send_job(int fd, ipc_handler_type type, */ n = write(fd, &job, sizeof(job) ); if (n<0) { - if (errno==EINTR) + if (errno==EAGAIN || errno==EWOULDBLOCK) + LM_CRIT("blocking detected while sending job type %d[%s] on %d " + " to proc id %d/%d [%s]\n", type, ipc_handlers[type].name, fd, + dst_proc, (dst_proc==-1)?-1:pt[dst_proc].pid , + (dst_proc==-1)?"n/a":pt[dst_proc].desc); + else if (errno==EINTR) goto again; - LM_ERR("sending job type %d[%s] on %d failed: %s\n", - type, ipc_handlers[type].name, fd, strerror(errno)); + else + LM_ERR("sending job type %d[%s] on %d failed: %s\n", + type, ipc_handlers[type].name, fd, strerror(errno)); return -1; } return 0; @@ -213,22 +219,24 @@ static inline int __ipc_send_job(int fd, ipc_handler_type type, int ipc_send_job(int dst_proc, ipc_handler_type type, void *payload) { - return __ipc_send_job(IPC_FD_WRITE(dst_proc), type, payload, NULL); + return __ipc_send_job(IPC_FD_WRITE(dst_proc), dst_proc, + type, payload, NULL); } int ipc_dispatch_job(ipc_handler_type type, void *payload) { - return __ipc_send_job(ipc_shared_pipe[1], type, payload, NULL); + return __ipc_send_job(ipc_shared_pipe[1], -1, type, payload, NULL); } int ipc_send_rpc(int dst_proc, ipc_rpc_f *rpc, void *param) { - return __ipc_send_job(IPC_FD_WRITE(dst_proc), ipc_rpc_type, rpc, param); + return __ipc_send_job(IPC_FD_WRITE(dst_proc), dst_proc, + ipc_rpc_type, rpc, param); } int ipc_dispatch_rpc( ipc_rpc_f *rpc, void *param) { - return __ipc_send_job(ipc_shared_pipe[1], ipc_rpc_type, rpc, param); + return __ipc_send_job(ipc_shared_pipe[1], -1, ipc_rpc_type, rpc, param); } int ipc_send_sync_reply(int dst_proc, void *param)