}
/* 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;
wasDirty = buf_Sync(1);
} /* whole daemon's while loop */
+
+ pthread_exit(NULL);
+ return NULL;
}
long
{
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 ) {
cm_data.buf_nOrigBuffers = cm_data.buf_nbuffers;
/* lower hash size to a prime number */
- cm_data.buf_hashSize = osi_PrimeLessThan((afs_uint32)(cm_data.buf_nbuffers/7 + 1));
+ cm_data.buf_hashSize = cm_NextHighestPowerOf2((afs_uint32)(cm_data.buf_nbuffers/7));
/* create hash table */
memset((void *)cm_data.buf_scacheHashTablepp, 0, cm_data.buf_hashSize * sizeof(cm_buf_t *));
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
long code;
long bufferPos;
afs_uint32 i;
+ afs_uint32 invalidate = 0;
/* assert that cm_bufCreateLock is held in write mode */
lock_AssertWrite(&scp->bufCreateLock);
lock_ReleaseWrite(&buf_globalLock);
}
} else {
- if (RDR_Initialized)
- RDR_InvalidateObject(scp->fid.cell, scp->fid.volume, scp->fid.vnode,
- scp->fid.unique, scp->fid.hash,
- scp->fileType, AFS_INVALIDATE_SMB);
+ invalidate = 1;
}
_InterlockedAnd(&bufp->flags, ~CM_BUF_DIRTY);
bufp->error = 0;
buf_ValidateBufQueues();
#endif /* TESTING */
+ if (invalidate && RDR_Initialized)
+ RDR_InvalidateObject(scp->fid.cell, scp->fid.volume, scp->fid.vnode,
+ scp->fid.unique, scp->fid.hash,
+ scp->fileType, AFS_INVALIDATE_SMB);
+
/* done */
return code;
}