From: Ben Kaduk Date: Thu, 11 Mar 2010 05:13:12 +0000 (-0500) Subject: Allocate and free backing store for event mutices X-Git-Tag: openafs-devel-1_5_73~53 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c9a4e11bbac143f7e44af4eb1e6fae1653679e33;p=packages%2Fo%2Fopenafs.git Allocate and free backing store for event mutices Actually get memory for the event mutex. With this and a locking tweak, afsd actually starts (with memcache; the UFS cache still has some locking issues). Note that struct mtx is small enough that we may want to just include it inline in afs_event_t and avoid having to do a separate allocation/free step. However, Derrick wants to merge the FBSD and DARWIN versions of this file, so stick with the more compatible version for now. I find that without the memset(), mtx_init() will (sometimes?) complain that the mutex is already initialized. The glock should ensure serialization here, though, so that we only allocate and initialize one mutex per event. Also remove an unnecessary cast while here. Change-Id: Ib304f4301a478a82f0fb8c9ae3bfee98a2a28acd Reviewed-on: http://gerrit.openafs.org/1560 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afs/FBSD/osi_sleep.c b/src/afs/FBSD/osi_sleep.c index 8a5bb6c55..b70d3c4a9 100644 --- a/src/afs/FBSD/osi_sleep.c +++ b/src/afs/FBSD/osi_sleep.c @@ -138,7 +138,9 @@ afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); + newp = osi_AllocSmallSpace(sizeof(afs_event_t)); + newp->lck = osi_AllocSmallSpace(sizeof(struct mtx)); + memset(newp->lck, 0, sizeof(struct mtx)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -247,6 +249,7 @@ shutdown_osisleep(void) { if (evp->refcount == 0) { EVTLOCK_DESTROY(evp); *pevpp = evp->next; + osi_FreeSmallSpace(evp->lck); osi_FreeSmallSpace(evp); afs_evhashcnt--; } else {