Esempio n. 1
0
static void
signal_cb(uv_signal_t *handle, int signum) {
    if (signum == SIGINT || signum == SIGQUIT) {
        char *name = signum == SIGINT ? "SIGINT" : "SIGQUIT";
        logger_log(LOG_INFO, "Received %s, scheduling shutdown...", name);

        close_signal();

        if (concurrency > 1) {
            struct server_context *servers = handle->data;
            for (int i = 0; i < concurrency; i++) {
                struct server_context *server = &servers[i];
                uv_async_send(&server->async_handle);
            }

        } else {
            struct resolver_context *dns = uv_key_get(&thread_resolver_key);
            resolver_shutdown(dns);
            struct server_context *ctx = handle->data;
            uv_close((uv_handle_t *)&ctx->tcp, NULL);
            if (ctx->udprelay) {
                udprelay_close(ctx);
            }
        }
    }
    if (signum == SIGTERM) {
        logger_log(LOG_INFO, "Received SIGTERM, scheduling shutdown...");
        if (daemon_mode) {
            delete_pidfile(pidfile);
        }
        exit(0);
    }
}
Esempio n. 2
0
/* sock_shutdown
**
** shutdown the socket library.  remember to call this when you're
** through using the lib
*/
void sock_shutdown(void)
{
#ifdef _WIN32
    WSACleanup();
#endif

    resolver_shutdown();
}
Esempio n. 3
0
static void
consumer_close(uv_async_t *handle) {
    struct server_context *server = container_of(handle, struct server_context, async_handle);

    uv_close((uv_handle_t*) &server->tcp, NULL);
    uv_close((uv_handle_t*) &server->async_handle, NULL);

    if (server->udprelay) {
        udprelay_close(server);
    }

    if (server->nameserver_num >= 0) {
        struct resolver_context *res = handle->loop->data;
        resolver_shutdown(res);
    }
}
Esempio n. 4
0
static void _shutdown_subsystems(void)
{
    fserve_shutdown();
    xslt_shutdown();
    refbuf_shutdown();
    slave_shutdown();
    auth_shutdown();
    yp_shutdown();
    stats_shutdown();

    global_shutdown();
    connection_shutdown();
    config_shutdown();
    resolver_shutdown();
    sock_shutdown();
    thread_shutdown();

    /* Now that these are done, we can stop the loggers. */
    _stop_logging();
    log_shutdown();

    xmlCleanupParser();
}
Esempio n. 5
0
void shutdown_subsystems(void)
{
    connection_shutdown();
    slave_shutdown();
    fserve_shutdown();
    stats_shutdown();
    stop_logging();

    config_shutdown();
    refbuf_shutdown();
    resolver_shutdown();
    sock_shutdown();

    DEBUG0 ("library cleanups");
#ifdef HAVE_CURL
    curl_global_cleanup();
#endif

    /* Now that these are done, we can stop the loggers. */
    log_shutdown();
    xslt_shutdown();
    thread_shutdown();
    global_shutdown();
}