示例#1
0
MEMCACHED_PUBLIC_API
EXTENSION_ERROR_CODE memcached_extensions_initialize(const char *config,
                                                     GET_SERVER_API get_server_api) {
    SERVER_HANDLE_V1 *server = get_server_api();
    union c99hack ch;
    cb_thread_t t;

    descriptor.get_name = get_name;
    if (server == NULL) {
        return EXTENSION_FATAL;
    }

    if (!server->extension->register_extension(EXTENSION_DAEMON, &descriptor)) {
        return EXTENSION_FATAL;
    }

    ch.exit_function = server->core->shutdown;
    if (cb_create_named_thread(&t, check_stdin_thread, ch.pointer, 1,
                               "mc:check_stdin") != 0) {
        perror("couldn't create stdin checking thread.");
        server->extension->unregister_extension(EXTENSION_DAEMON, &descriptor);
        return EXTENSION_FATAL;
    }

    return EXTENSION_SUCCESS;
}
示例#2
0
int cb_create_thread(cb_thread_t *id,
                     cb_thread_main_func func,
                     void *arg,
                     int detached)
{
    // Implemented in terms of cb_create_named_thread; with a NULL name.
    return cb_create_named_thread(id, func, arg, detached, NULL);
}