diff options
Diffstat (limited to 'src/plugin.c')
-rw-r--r-- | src/plugin.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/plugin.c b/src/plugin.c index 3219f4b..1b54d81 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -47,18 +47,13 @@ #include <slapi-plugin.h> #endif -#ifdef USE_PTHREADS -#include <pthread.h> -#endif - +#include "wrap.h" #include "dispatch.h" #include "map.h" #include "nis.h" #include "plugin.h" #include "portmap.h" -#define PACKAGE_VERSION "0.0" - /* the module initialization function */ static Slapi_PluginDesc plugin_description = { @@ -115,32 +110,14 @@ plugin_startup(Slapi_PBlock *pb) } } } -#if defined(USE_PTHREADS) /* Start a new listening thread to handle incoming traffic. */ - if (pthread_create(&state->tid, NULL, &dispatch_thread, state) != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, - plugin_description.spd_id, - "error starting listener thread\n"); - return -1; - } -#elif defined(USE_NSPR_THREADS) - /* Start a new listening thread to handle incoming traffic. */ - state->tid = PR_CreateThread(PR_USER_THREAD, - &dispatch_thread, - state, - PR_PRIORITY_NORMAL, - PR_GLOBAL_THREAD, - PR_JOINABLE_THREAD, - 0); + state->tid = wrap_start_thread(&dispatch_thread, state); if (state->tid == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id, "error starting listener thread\n"); return -1; } -#else -#error "Don't know how to start a thread for your server!" -#endif slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id, "plugin startup completed\n"); return 0; @@ -152,6 +129,7 @@ plugin_shutdown(Slapi_PBlock *pb) { struct plugin_state *state; slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); + wrap_stop_thread(state->tid); if (state->pmap_client_socket != -1) { /* Clear our registration with the portmapper. */ portmap_unregister(plugin_description.spd_id, |