From 32dd26f4052b57bf1cdc7fad2cc47874ff989cc1 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Thu, 29 May 2008 18:32:21 -0400 Subject: - switch to creating a PRThread instead of a pthread --- src/plugin.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/plugin.c') diff --git a/src/plugin.c b/src/plugin.c index a0f604d..3219f4b 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,10 @@ #include #endif +#ifdef USE_PTHREADS +#include +#endif + #include "dispatch.h" #include "map.h" #include "nis.h" @@ -112,14 +115,32 @@ plugin_startup(Slapi_PBlock *pb) } } } - /* Start a new listening thread to handle incoming traffic. FIXME: - * switch to using NSPR's threading facilities. */ +#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); + 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; -- cgit