Skip to content

Commit

Permalink
Proper fix for core status setting upon shutdown
Browse files Browse the repository at this point in the history
Use a lighter version of sr_set_core_status() in order to avoid any shm / locking / event related operations when setting the shutdown core status.
(see original report and workaround e7b8084)

(cherry picked from commit 49d3888)
  • Loading branch information
bogdan-iancu committed Sep 6, 2022
1 parent f694d9c commit c2da73f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void shutdown_opensips( int status )
int i, n, p;
int chld_status;

sr_set_core_status( STATE_TERMINATING, MI_SSTR("shutting down"));
sr_set_core_status_terminating();

/* terminate all processes */

Expand Down
13 changes: 13 additions & 0 deletions status_report.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,19 @@ int sr_set_core_status(int status, char *txt_s, int txt_len)
}


/* light version of set_core_status, doing no shm, locking or event
* operations - such ops are potentially dangerous during shutdonw */
void sr_set_core_status_terminating( void )
{
sri_core->status = STATE_TERMINATING;
/* note: the below assigment will produce a small mem leak in shm
* (for the previously allocated status), but we do not really care
* as we do this only once, at shutdown */
sri_core->status_txt.s = "shutting down";
sri_core->status_txt.len = 13;
}


int sr_get_core_status(void)
{
return sri_core->status;
Expand Down
2 changes: 2 additions & 0 deletions status_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ enum sr_core_states { STATE_NONE=-100, STATE_TERMINATING=-2,

int sr_set_core_status(int status, char *txt_s, int txt_len);

void sr_set_core_status_terminating( void );

int sr_get_core_status(void);

int sr_add_core_report(char *report_s, int report_len);
Expand Down

0 comments on commit c2da73f

Please sign in to comment.