Exemplo n.º 1
0
/**
 * @brief stop a connection
 * @param c the connection to stop
 */
void stop_connection(conn_node *c) {
  stop_children(c); // stop children and wait them to gracefully exits.
  close(c->fd); // stop the reader
  control_deactivate(&(c->control));
  control_deactivate(&(c->incoming.control));   // stop the worker
  control_deactivate(&(c->outcoming.control));  // stop the writer
}
Exemplo n.º 2
0
void
proc_finish(void)
{
	if (my_proc.nr_children) stop_children();
	log_debug(LOG_PROC, "%s process %d finished\n", my_proc.desc, getpid());
	exit(0);
}
Exemplo n.º 3
0
/* do a clean exit */
void clean_exit(int sig) {
    gm_log( GM_LOG_TRACE, "clean_exit(%d)\n", sig);

    if(mod_gm_opt->pidfile != NULL)
        unlink(mod_gm_opt->pidfile);

    /* stop all children */
    stop_children(GM_WORKER_STOP);

    /* detach shm */
    if(shmdt(shm) < 0)
        perror("shmdt");

    /*
     * clean up shared memory
     * will be removed when last client detaches
     */
    if( shmctl( shmid, IPC_RMID, 0 ) == -1 ) {
        perror("shmctl");
    } else {
        gm_log( GM_LOG_DEBUG, "shared memory deleted\n");
    }

    gm_log( GM_LOG_INFO, "mod_gearman worker exited\n");
    mod_gm_free_opt(mod_gm_opt);
    exit( EXIT_SUCCESS );
}
Exemplo n.º 4
0
/* try to reload the config */
void reload_config(int sig) {
    gm_log( GM_LOG_TRACE, "reload_config(%d)\n", sig);
    if(parse_arguments(orig_argc, orig_argv) != GM_OK) {
        gm_log( GM_LOG_ERROR, "reload config failed, check your config\n");
        return;
    }

    /*
     * restart workers gracefully:
     * send term signal to our children
     * children will finish the current job and exit
     */
    stop_children(GM_WORKER_RESTART);

    /* start status worker */
    make_new_child(GM_WORKER_STATUS);

    gm_log( GM_LOG_INFO, "reloading config was successful\n");

    return;
}