Windows: convert buf_IncrSyncer to pthreads
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 2 Dec 2011 16:11:59 +0000 (11:11 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 2 Dec 2011 23:52:13 +0000 (15:52 -0800)
buf_IncrSyncer() calls rx therefore it should be a pthread
thread so as not to count against the 63 native thread count
limit.

Change-Id: If00eeb7d26bfbf7d0f35addb05290f3704d11a89
Reviewed-on: http://gerrit.openafs.org/6171
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_buf.c

index 88e4eb2..96f9f67 100644 (file)
@@ -337,7 +337,8 @@ buf_Sync(int quitOnShutdown)
 }
 
 /* incremental sync daemon.  Writes all dirty buffers every 5000 ms */
-void buf_IncrSyncer(long parm)
+static void *
+buf_IncrSyncer(void * parm)
 {
     long wasDirty = 0;
     long i;
@@ -353,6 +354,9 @@ void buf_IncrSyncer(long parm)
 
         wasDirty = buf_Sync(1);
     } /* whole daemon's while loop */
+
+    pthread_exit(NULL);
+    return NULL;
 }
 
 long
@@ -461,9 +465,10 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers)
 {
     static osi_once_t once;
     cm_buf_t *bp;
-    thread_t phandle;
+    pthread_t phandle;
+    pthread_attr_t tattr;
+    int pstatus;
     long i;
-    unsigned long pid;
     char *data;
 
     if ( newFile ) {
@@ -602,12 +607,13 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers)
         osi_EndOnce(&once);
 
         /* and create the incr-syncer */
-        phandle = thrd_Create(0, 0,
-                               (ThreadFunc) buf_IncrSyncer, 0, 0, &pid,
-                               "buf_IncrSyncer");
+        pthread_attr_init(&tattr);
+        pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
+
+        pstatus = pthread_create(&phandle, &tattr, buf_IncrSyncer, 0);
+        osi_assertx(pstatus == 0, "buf: can't create incremental sync proc");
 
-        osi_assertx(phandle != NULL, "buf: can't create incremental sync proc");
-        CloseHandle(phandle);
+        pthread_attr_destroy(&tattr);
     }
 
 #ifdef TESTING