Skip to content

Commit

Permalink
Timer process counting: Drop obsolete code
Browse files Browse the repository at this point in the history
The timer counting and timer status code reporting logic was reworked in
caabbe5 (from N timer processes to 1+1, later 1+1+1), so the
"init_timer_no" shared integer logic is no longer needed.

(cherry picked from commit ed905d1)
  • Loading branch information
liviuchircu committed Jan 8, 2020
1 parent 8225988 commit 9434c5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
38 changes: 1 addition & 37 deletions daemonize.c
Expand Up @@ -66,15 +66,14 @@
char *startup_wdir = NULL;

static int status_pipe[2];
static int *init_timer_no;

static enum opensips_states *osips_state = NULL;

/* creates the status pipe which will be used for
* proper status code returning
*
* must be called before any forking */
int create_status_pipe( int no_timers )
int create_status_pipe(void)
{
int rc;

Expand All @@ -87,31 +86,9 @@ int create_status_pipe( int no_timers )
goto retry;

LM_DBG("pipe created ? rc = %d, errno = %s\n",rc,strerror(errno));

if (no_timers)
return rc;

/* also create SHM var which the attendent will use
* to notify us about the overall number of timers
* that need init
*
* at this point we do not know how many timers we will need */
init_timer_no = shm_malloc(sizeof(int));
if (!init_timer_no) {
LM_ERR("no more shm\n");
return -1;
}

*init_timer_no = 0;
return rc;
}

void inc_init_timer(void)
{
LM_DBG("incrementing init timer no\n");
(*init_timer_no)++;
}

/* attempts to send the val
* status code to the waiting end */
int send_status_code(char val)
Expand Down Expand Up @@ -181,19 +158,6 @@ int wait_for_all_children(void)
return -1;
}

/* we got this far, means everything went ok with
* SIP listeners and module procs
*
* still need to see if
* timers initialized ok */

for (i=0;i<*init_timer_no;i++) {
LM_DBG("waiting for timer\n");
ret = wait_status_code(&rc);
if (ret < 0 || rc < 0 )
return -1;
}

return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions daemonize.h
Expand Up @@ -37,10 +37,9 @@ int set_core_dump(int enable, unsigned int size);
int send_status_code(char val);
void clean_read_pipeend(void);
void clean_write_pipeend(void);
int create_status_pipe(int no_timers);
int create_status_pipe(void);
int wait_for_one_child(void);
int wait_for_all_children(void);
void inc_init_timer(void);

enum opensips_states {STATE_NONE, STATE_STARTING,
STATE_RUNNING, STATE_TERMINATING};
Expand Down
4 changes: 2 additions & 2 deletions main.c
Expand Up @@ -855,7 +855,7 @@ static int main_loop(void)
if (auto_scaling_enabled) {
/* re-create the status pipes to collect the status of the
* dynamically forked processes */
if (create_status_pipe(1) < 0) {
if (create_status_pipe() < 0) {
LM_ERR("failed to create status pipe\n");
goto error;
}
Expand Down Expand Up @@ -1280,7 +1280,7 @@ int main(int argc, char** argv)
goto error;
}

if (create_status_pipe(0) < 0) {
if (create_status_pipe() < 0) {
LM_ERR("failed to create status pipe\n");
goto error;
}
Expand Down

0 comments on commit 9434c5b

Please sign in to comment.