From 1ff337990341a9d2a943b6ef63ac102dccc997c8 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Sat, 11 Jan 2003 07:48:58 +0000 Subject: [PATCH] STABLE12-rx-avoid-using-newproc-on-solaris-20020812 Second attempt at avoiding the use of newproc() on Solaris. This time, use thread_create to spawn a kernel thread, and use a dummy packet to wake up the listener during shutdown. (cherry picked from commit 5d3545610b83905e220d18c948d0fc621db851a5) --- src/rx/SOLARIS/rx_knet.c | 14 ++++++++++++-- src/rx/rx_kcommon.c | 14 +++++--------- src/rx/rx_kcommon.h | 1 + src/rx/rx_pthread.c | 6 +++--- src/rx/rx_rdwr.c | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/rx/SOLARIS/rx_knet.c b/src/rx/SOLARIS/rx_knet.c index a2a75ca0c..bd2f1faf5 100644 --- a/src/rx/SOLARIS/rx_knet.c +++ b/src/rx/SOLARIS/rx_knet.c @@ -292,11 +292,21 @@ int osi_FreeSocket(asocket) { extern int rxk_ListenerPid; struct sonode *so = (struct sonode *)asocket; - vnode_t *vp = SOTOV(so); + struct sockaddr_in taddr; + struct iovec dvec; + char c; AFS_STATCNT(osi_FreeSocket); + + taddr.sin_family = AF_INET; + taddr.sin_port = htons(rx_port); + taddr.sin_addr.s_addr = htonl(0x7f000001); + + dvec.iov_base = &c; + dvec.iov_len = 1; + while (rxk_ListenerPid) { - kill(rxk_ListenerPid, SIGUSR1); + osi_NetSend(rx_socket, &taddr, &dvec, 1, 1, 0); afs_osi_Sleep(&rxk_ListenerPid); } diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index eadc1a38e..4105a72fc 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -1024,14 +1024,15 @@ int rxk_ListenerPid; /* Used to signal process to wakeup at shutdown */ #ifdef AFS_SUN5_ENV /* - * Run the listener as a kernel process. + * Run the listener as a kernel thread. */ void rxk_Listener(void) { extern id_t syscid; void rxk_ListenerProc(void); - if (newproc(rxk_ListenerProc, syscid, 59)) - osi_Panic("rxk_Listener: failed to fork listener process!\n"); + if (thread_create(NULL, DEFAULTSTKSZ, rxk_ListenerProc, + 0, 0, &p0, TS_RUN, minclsyspri) == NULL) + osi_Panic("rxk_Listener: failed to start listener thread!\n"); } void rxk_ListenerProc(void) @@ -1047,7 +1048,7 @@ void rxk_Listener(void) rxk_ListenerPid = current->pid; #endif #ifdef AFS_SUN5_ENV - rxk_ListenerPid = ttoproc(curthread)->p_pidp->pid_id; + rxk_ListenerPid = 1; /* No PID, just a flag that we're alive */ #endif /* AFS_SUN5_ENV */ #ifdef AFS_FBSD_ENV rxk_ListenerPid = curproc->p_pid; @@ -1091,11 +1092,6 @@ void rxk_Listener(void) #endif #ifdef AFS_SUN5_ENV AFS_GUNLOCK(); -#ifdef HAVE_P_COREFILE - if (!curproc->p_corefile) /* newproc doesn't set it, but exit frees it */ - curproc->p_corefile = refstr_alloc("core"); -#endif - exit(CLD_EXITED, 0); #endif /* AFS_SUN5_ENV */ } diff --git a/src/rx/rx_kcommon.h b/src/rx/rx_kcommon.h index 4ac04c2c4..0eacd8aae 100644 --- a/src/rx/rx_kcommon.h +++ b/src/rx/rx_kcommon.h @@ -30,6 +30,7 @@ typedef unsigned short etap_event_t; #include "../h/vfs.h" /* stops SUN56 socketvar.h warnings */ #include "../h/stropts.h" /* stops SUN56 socketvar.h warnings */ #include "../h/stream.h" /* stops SUN56 socketvar.h errors */ +#include "../h/disp.h" #endif #include "../h/socket.h" #ifndef AFS_LINUX22_ENV diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index 295913f24..17f88813a 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -53,7 +53,7 @@ static long rx_pthread_n_event_wakeups; */ static int rx_pthread_event_rescheduled = 0; -static void rx_ListenerProc(void *); +static void *rx_ListenerProc(void *); /* * We supply an event handling thread for Rx's event processing. @@ -204,7 +204,7 @@ int sock; int *tnop; struct rx_call **newcallp; { - u_long host; + unsigned int host; u_short port; register struct rx_packet *p = (struct rx_packet *)0; @@ -245,7 +245,7 @@ struct rx_call **newcallp; /* This is the listener process request loop. The listener process loop * becomes a server thread when rxi_ListenerProc returns, and stays * server thread until rxi_ServerProc returns. */ -static void rx_ListenerProc(void *argp) +static void *rx_ListenerProc(void *argp) { int threadID; int sock = (int) argp; diff --git a/src/rx/rx_rdwr.c b/src/rx/rx_rdwr.c index ffadf87e0..19d532c08 100644 --- a/src/rx/rx_rdwr.c +++ b/src/rx/rx_rdwr.c @@ -1065,7 +1065,7 @@ int rx_WritevAlloc(call, iov, nio, maxio, nbytes) int maxio; int nbytes; { - int bytes; + char bytes; SPLVAR; NETPRI; -- 2.39.5