diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-29 18:32:21 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-29 18:32:21 -0400 |
| commit | 32dd26f4052b57bf1cdc7fad2cc47874ff989cc1 (patch) | |
| tree | 586ce4398ea36ba4936503f50be568b2806127ae /src/plugin.c | |
| parent | ca79c5d953727a31583520ef882316edd62e3bc3 (diff) | |
| download | slapi-nis-32dd26f4052b57bf1cdc7fad2cc47874ff989cc1.tar.gz slapi-nis-32dd26f4052b57bf1cdc7fad2cc47874ff989cc1.tar.xz slapi-nis-32dd26f4052b57bf1cdc7fad2cc47874ff989cc1.zip | |
- switch to creating a PRThread instead of a pthread
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; |
