lwp: zero reused request blocks
[openafs.git] / src / lwp / iomgr.c
index 74df517..64e9f9c 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <malloc.h>
-extern void lwp_abort(void);
-#else
-#include <unistd.h>            /* select() prototype */
-#include <sys/types.h>         /* fd_set on older platforms */
-#include <sys/time.h>          /* struct timeval, select() prototype */
-#ifndef FD_SET
-# include <sys/select.h>       /* fd_set on newer platforms */
-#endif
-#include <sys/file.h>
-#endif /* AFS_NT40_ENV */
-#include "lwp.h"
-#include "timer.h"
-#include <signal.h>
-#include <errno.h>
-#ifdef AFS_SUN5_ENV
-#include <fcntl.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
 #endif
 
-#if    defined(USE_PTHREADS) || defined(USE_SOLARIS_THREADS)
+#include <afs/opr.h>
 
-void IOMGR_Initialize()        /* noop */
-{ }
-
-void IOMGR_Sleep (seconds)
-  unsigned seconds;
-{
-    struct timespec itv;
-
-    itv.tv_sec = seconds;
-    itv.tv_nsec = 0;
-    MUTEX_EXIT(&lwp_mutex);
-    osi_Assert(pthread_delay_np(&itv) == 0);
-    MUTEX_ENTER(&lwp_mutex);
-}
-
-#else
-
-#ifdef AFS_DECOSF_ENV
-extern void *malloc();
-#endif /* AFS_DECOSF_ENV */
+#include "lwp.h"
+#include "timer.h"
 
 typedef unsigned char bool;
 #define FALSE  0
@@ -195,7 +158,7 @@ fd_set *IOMGR_AllocFDSet(void)
        iomgrFreeFDSets = iomgrFreeFDSets->next;
     }
     else {
-       t = (struct IOMGR_fd_set *)malloc(sizeof(fd_set));
+       t = malloc(sizeof(fd_set));
     }
     if (!t)
        return (fd_set*)0;
@@ -211,11 +174,11 @@ static struct IoRequest *NewRequest(void)
 {
     struct IoRequest *request;
 
-    if ((request=iorFreeList))
+    if ((request=iorFreeList)) {
        iorFreeList = (struct IoRequest *) (request->next);
-    else request = (struct IoRequest *) malloc(sizeof(struct IoRequest));
+       memset(request, 0, sizeof(struct IoRequest));
+    } else request = calloc(1, sizeof(struct IoRequest));
 
-    memset((char*)request, 0, sizeof(struct IoRequest));
     return request;
 }
 
@@ -587,7 +550,7 @@ static void *IOMGR(void *dummy)
                  }
 #endif
                  iomgr_errno = errno;
-                 lwp_abort();
+                 opr_abort();
               }
            }
 
@@ -869,7 +832,7 @@ int IOMGR_Select(int fds, fd_set *readfds, fd_set *writefds,
        fprintf(stderr, "IOMGR_Select: fds=%d, more than max %d\n",
                fds, FD_SETSIZE);
        fflush(stderr);
-       lwp_abort();
+       opr_abort();
     }
 #endif
 
@@ -1020,4 +983,3 @@ void IOMGR_Sleep (int seconds)
     timeout.tv_usec = 0;
     IOMGR_Select(0, 0, 0, 0, &timeout);
 }
-#endif /* USE_PTHREADS */