diff options
Diffstat (limited to 'src/plugin.c')
| -rw-r--r-- | src/plugin.c | 27 |
1 files changed, 24 insertions, 3 deletions
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 <errno.h> #include <netinet/in.h> #include <poll.h> -#include <pthread.h> #include <stdlib.h> #include <string.h> #include <syslog.h> @@ -48,6 +47,10 @@ #include <slapi-plugin.h> #endif +#ifdef USE_PTHREADS +#include <pthread.h> +#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; |
