Moved the writing to and closing of the parent-child pipe to a separate function.
This commit is contained in:
@ -213,6 +213,7 @@ static bool resolve_maxscale_conf_fname(
|
|||||||
static char* check_dir_access(char* dirname,bool,bool);
|
static char* check_dir_access(char* dirname,bool,bool);
|
||||||
static int set_user();
|
static int set_user();
|
||||||
bool pid_file_exists();
|
bool pid_file_exists();
|
||||||
|
void write_child_exit_code(int fd, int code);
|
||||||
/** SSL multi-threading functions and structures */
|
/** SSL multi-threading functions and structures */
|
||||||
|
|
||||||
static SPINLOCK* ssl_locks;
|
static SPINLOCK* ssl_locks;
|
||||||
@ -1450,8 +1451,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if(parent_process)
|
if(parent_process)
|
||||||
{
|
{
|
||||||
int nread = read(daemon_pipe[0],(void*)&child_status,sizeof(int));
|
|
||||||
close(daemon_pipe[1]);
|
close(daemon_pipe[1]);
|
||||||
|
int nread = read(daemon_pipe[0],(void*)&child_status,sizeof(int));
|
||||||
close(daemon_pipe[0]);
|
close(daemon_pipe[0]);
|
||||||
|
|
||||||
if(nread == -1)
|
if(nread == -1)
|
||||||
@ -1951,8 +1952,7 @@ int main(int argc, char **argv)
|
|||||||
* Successful start, notify the parent process that it can exit.
|
* Successful start, notify the parent process that it can exit.
|
||||||
*/
|
*/
|
||||||
ss_dassert(rc == MAXSCALE_SHUTDOWN);
|
ss_dassert(rc == MAXSCALE_SHUTDOWN);
|
||||||
write(daemon_pipe[1],&rc,sizeof(int));
|
write_child_exit_code(daemon_pipe[1], rc);
|
||||||
close(daemon_pipe[1]);
|
|
||||||
|
|
||||||
MaxScaleStarted = time(0);
|
MaxScaleStarted = time(0);
|
||||||
/*<
|
/*<
|
||||||
@ -1996,8 +1996,7 @@ return_main:
|
|||||||
if(daemon_mode && rc != MAXSCALE_SHUTDOWN)
|
if(daemon_mode && rc != MAXSCALE_SHUTDOWN)
|
||||||
{
|
{
|
||||||
/** Notify the parent process that an error has occurred */
|
/** Notify the parent process that an error has occurred */
|
||||||
write(daemon_pipe[1],&rc,sizeof(int));
|
write_child_exit_code(daemon_pipe[1], rc);
|
||||||
close(daemon_pipe[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threads)
|
if (threads)
|
||||||
@ -2488,3 +2487,14 @@ static int set_user(char* user)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the exit status of the child process to the parent process.
|
||||||
|
* @param fd File descriptor to write to
|
||||||
|
* @param code Exit status of the child process
|
||||||
|
*/
|
||||||
|
void write_child_exit_code(int fd, int code)
|
||||||
|
{
|
||||||
|
/** Notify the parent process that an error has occurred */
|
||||||
|
write(fd, &code, sizeof (int));
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user