Skip to content

Commit

Permalink
[core] improve logging when IPC blocking is detected
Browse files Browse the repository at this point in the history
Throw a CRITical log with info on the target process
  • Loading branch information
bogdan-iancu committed Nov 5, 2021
1 parent 62af720 commit dce2643
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions ipc.c
Expand Up @@ -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;
Expand All @@ -202,33 +202,41 @@ 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;
}

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)
Expand Down

0 comments on commit dce2643

Please sign in to comment.