linux-rx-listener-flush-signals-20030605
[openafs.git] / src / rx / LINUX / rx_knet.c
index 37a39f4..efe9a40 100644 (file)
  *
  * Linux implementation.
  */
-#include "../afs/param.h"
+#include <afsconfig.h>
+#include "afs/param.h"
+
+RCSID("$Header$");
+
+#include <linux/version.h>
 #ifdef AFS_LINUX22_ENV
-#include "../rx/rx_kcommon.h"
+#include "rx/rx_kcommon.h"
 #if defined(AFS_LINUX24_ENV)
-#include "../h/smp_lock.h"
+#include "h/smp_lock.h"
 #endif
 #include <asm/uaccess.h>
 
@@ -54,8 +59,7 @@ struct osi_socket *rxk_NewSocket(short aport)
 
 
 /* free socket allocated by osi_NetSocket */
-int rxk_FreeSocket(asocket)
-    register struct socket *asocket;
+int rxk_FreeSocket(register struct socket *asocket)
 {
     AFS_STATCNT(osi_FreeSocket);
     return 0;
@@ -68,8 +72,8 @@ int rxk_FreeSocket(asocket)
  * 0 = success
  * non-zero = failure
  */
-int osi_NetSend(struct socket *sop, struct sockaddr_in *to,
-               struct iovec *iov, int iovcnt, int size, int istack)
+int osi_NetSend(osi_socket sop, struct sockaddr_in *to,
+               struct iovec *iov, int iovcnt, afs_int32 size, int istack)
 {
     KERNEL_SPACE_DECL;
     struct msghdr msg;
@@ -171,12 +175,22 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *from,
 
 void osi_StopListener(void)
 {
-    extern int (*sys_killp)();
+    struct task_struct *listener;
     extern int rxk_ListenerPid;
 
-    if (rxk_ListenerPid) {
-       (void) (*sys_killp)(rxk_ListenerPid, 9);
-       rxk_ListenerPid = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+    read_lock(&tasklist_lock);
+#endif
+    listener =  find_task_by_pid(rxk_ListenerPid);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+    read_unlock(&tasklist_lock);
+#endif
+    while (rxk_ListenerPid) {
+       struct task_struct *p;
+
+       flush_signals(listener);
+       force_sig(SIGKILL, listener);
+       afs_osi_Sleep(&rxk_ListenerPid); 
     }
     sock_release(rx_socket);
     rx_socket = NULL;