From: Jeffrey Altman Date: Fri, 2 Dec 2011 16:11:59 +0000 (-0500) Subject: Windows: convert buf_IncrSyncer to pthreads X-Git-Tag: openafs-stable-1_8_0pre1~2992 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=b26161284fef682e570377e70c7ebe5b6e8902fb Windows: convert buf_IncrSyncer to pthreads 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 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 88e4eb2..96f9f67 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -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