Ejemplo n.º 1
0
static void master_main()
{
    setProcTitle ( "master process", 1 );

    _process_chdir = process_chdir;

    if ( !new_thread ( process_checker ) ) {
        perror ( "process checker thread error!" );
        exit ( -1 );
    }

    int i = 0;

    while ( 1 ) {
        if ( checkProcessForExit() ) {
            kill ( 0, SIGTERM ); /// 关闭子进程
            on_master_exit_handler ( 0, NULL, NULL );
            exit ( 0 );
        }

        struct timespec timeout;

        timeout.tv_sec = 1;

        timeout.tv_nsec = 0;

        while ( nanosleep ( &timeout, &timeout ) && errno == EINTR );

        i++;
    }
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: no2key/alilua
static void *process_checker()
{
    while ( 1 ) {
        if ( !checkProcessForExit() ) {
            safeProcess();
        }

        sleep ( 1 );
    }
}
Ejemplo n.º 3
0
static int without_jobs()
{
    check_lua_sleep_timeouts();
    check_timeouts();

    if ( checkProcessForExit() || has_error_for_exit ) {
        //network_send_error ( epd, 500, "Child Process restart!" );
        //close_client ( epd );
    }

    sync_serv_status();

    do_other_jobs();
}
Ejemplo n.º 4
0
static void *process_checker()
{
    while ( 1 ) {
        if ( !checkProcessForExit() ) {
            safeProcess();
        }

        struct timespec timeout;

        timeout.tv_sec = 1;

        timeout.tv_nsec = 0;

        while ( nanosleep ( &timeout, &timeout ) && errno == EINTR );
    }
}
Ejemplo n.º 5
0
void network_worker ( void *_process_func, int process_count, int process_at )
{
    if ( sizeof ( epdata_t ) != 4096 ) {
        printf ( "warning sizof(epdata_t) = %ld\n", sizeof ( epdata_t ) );    // must be 4096
    }

    signal ( SIGPIPE, SIG_IGN );

    _shm_serv_status = shm_malloc ( sizeof ( serv_status_t ) );

    if ( _shm_serv_status == NULL ) {
        perror ( "shm malloc failed\n" );
        signal ( SIGHUP, SIG_IGN );
        exit ( 1 );
    }

    shm_serv_status = _shm_serv_status->p;
    memcpy ( shm_serv_status, &serv_status, sizeof ( serv_status_t ) );

    process_func = _process_func;

    init_mime_types();

    loop_fd = se_create ( EPD_POOL_SIZE );
    set_loop_fd ( loop_fd, process_count );

    se_ptr_t *se = se_add ( loop_fd, server_fd, NULL );

    se_be_read ( se, network_be_accept );

    while ( 1 ) {

        se_loop ( loop_fd, EPOLL_WAITOUT, without_jobs );

        if ( checkProcessForExit() || has_error_for_exit ) {
            break;
        }
    }
}
Ejemplo n.º 6
0
Archivo: main.c Proyecto: no2key/alilua
static void master_main()
{
    setProcTitle ( "master process", 1 );

    _process_chdir = process_chdir;

    if ( !new_thread ( process_checker ) ) {
        perror ( "process checker thread error!" );
        exit ( -1 );
    }

    int i = 0;

    while ( 1 ) {
        if ( checkProcessForExit() ) {
            kill ( 0, SIGTERM ); /// 关闭子进程
            on_master_exit_handler ( 0, NULL, NULL );
            exit ( 0 );
        }

        sleep ( 1 );
        i++;
    }
}