Skip to content

Commit

Permalink
Fix race condition on reporting successful per-proc cfg reload
Browse files Browse the repository at this point in the history
Set the initial per-proc reload status (to SENT) before actually sending the IPC job, to avoid any race condition (in updating the status) with the IPC callback (ran in the target process).

Fixes #2584
Many thanks to @etamme on providing the troubleshooting logs

(cherry picked from commit e85072c)
  • Loading branch information
bogdan-iancu committed Jan 4, 2022
1 parent 8e30459 commit cb813ba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cfg_reload.c
Expand Up @@ -274,10 +274,16 @@ static inline void send_cmd_to_all_procs(ipc_rpc_f *rpc)
for( i=1 ; i<counted_max_processes ; i++) {
if ( (pt[i].flags&(OSS_PROC_NO_IPC|OSS_PROC_NEEDS_SCRIPT))==
OSS_PROC_NEEDS_SCRIPT ) {
if (ipc_send_rpc( i, rpc, (void*)(long)srr_ctx->seq_no)<0)
srr_ctx->proc_status[i] = RELOAD_FAILED;
else
srr_ctx->proc_status[i] = RELOAD_SENT;
/* set the status before sending, to avoid any race condition
* with running the callback function */
srr_ctx->proc_status[i] = RELOAD_SENT;
if (i==process_no) {
/* run line the cmd for the proc itself */
rpc( process_no, (void*)(long)srr_ctx->seq_no);
} else {
if (ipc_send_rpc( i, rpc, (void*)(long)srr_ctx->seq_no)<0)
srr_ctx->proc_status[i] = RELOAD_FAILED;
}
}
}
}
Expand Down

0 comments on commit cb813ba

Please sign in to comment.