summaryrefslogtreecommitdiff
path: root/nfsd/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'nfsd/main.c')
-rw-r--r--nfsd/main.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/nfsd/main.c b/nfsd/main.c
index ee071090..d5607d37 100644
--- a/nfsd/main.c
+++ b/nfsd/main.c
@@ -24,6 +24,7 @@
#include <rpc/pmap_prot.h>
#include <maptime.h>
#include <hurd.h>
+#include <pthread.h>
#include <error.h>
int main_udp_socket, pmap_udp_socket;
@@ -31,6 +32,22 @@ struct sockaddr_in main_address, pmap_address;
static char index_file[] = LOCALSTATEDIR "/state/misc/nfsd.index";
char *index_file_name = index_file;
+/* Launch a server loop thread */
+static void
+create_server_thread (int socket)
+{
+ pthread_t thread;
+ int fail;
+
+ fail = pthread_create (&thread, NULL, server_loop, (void *) socket);
+ if (fail)
+ error (1, fail, "Creating main server thread");
+
+ fail = pthread_detach (thread);
+ if (fail)
+ error (1, fail, "Detaching main server thread");
+}
+
int
main (int argc, char **argv)
{
@@ -73,12 +90,10 @@ main (int argc, char **argv)
init_filesystems ();
- cthread_detach (cthread_fork ((cthread_fn_t) server_loop,
- (any_t)(intptr_t) pmap_udp_socket));
+ create_server_thread (pmap_udp_socket);
while (nthreads--)
- cthread_detach (cthread_fork ((cthread_fn_t) server_loop,
- (any_t)(intptr_t) main_udp_socket));
+ create_server_thread (main_udp_socket);
for (;;)
{