From c9a4e11bbac143f7e44af4eb1e6fae1653679e33 Mon Sep 17 00:00:00 2001 From: Ben Kaduk Date: Thu, 11 Mar 2010 00:13:12 -0500 Subject: [PATCH] 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 --- src/afs/FBSD/osi_sleep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 { -- 2.39.5