Changeset: 3c5989096248 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3c5989096248
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_system.h
sql/common/sql_list.c
Branch: default
Log Message:
Merge with Jan2014 branch.
diffs (138 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -120,17 +120,20 @@ static int BBPbackup(BAT *b, bit subcomm
#define BBPnamecheck(s) (BBPtmpcheck(s) ? ((s)[3] == '_' ? strtol((s) + 4,
NULL, 8) : -strtol((s) + 5, NULL, 8)) : 0)
-static int stamp = 0;
+#ifdef ATOMIC_LOCK
+static MT_Lock stampLock MT_LOCK_INITIALIZER("stampLock");
+#endif
+static volatile ATOMIC_TYPE stamp = 0;
static inline int
BBPstamp(void)
{
- return ++stamp;
+ return (int) ATOMIC_INC(stamp, stampLock, "BBPstamp");
}
static void
BBPsetstamp(int newstamp)
{
- stamp = newstamp;
+ ATOMIC_SET(stamp, newstamp, stampLock, "BBPsetstamp");
}
@@ -973,6 +976,7 @@ BBPinit(void)
#ifdef NEED_MT_LOCK_INIT
MT_lock_init(&GDKunloadLock, "GDKunloadLock");
+ ATOMIC_INIT(stampLock, "stampLock");
#endif
/* first move everything from SUBDIR to BAKDIR (its parent) */
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -252,28 +252,42 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
(l)->count = (l)->contention = (l)->sleep = 0; \
(l)->name = (n); \
_DBG_LOCK_LOCKER(l, NULL); \
- while (ATOMIC_TAS(GDKlocklistlock, dummy, "") != 0) \
- ; \
- (l)->next = GDKlocklist; \
- GDKlocklist = (l); \
- ATOMIC_CLEAR(GDKlocklistlock, dummy, ""); \
+ /* if name starts with "sa_" don't link in GDKlocklist */ \
+ /* since the lock is in memory that is governed by the */ \
+ /* SQL storage allocator, and hence we have no control */ \
+ /* over when the lock is destroyed and the memory freed */ \
+ if (strncmp((n), "sa_", 3) != 0) { \
+ while (ATOMIC_TAS(GDKlocklistlock, dummy, "") != 0) \
+ ; \
+ (l)->next = GDKlocklist; \
+ GDKlocklist = (l); \
+ ATOMIC_CLEAR(GDKlocklistlock, dummy, ""); \
+ } else { \
+ (l)->next = NULL; \
+ } \
} while (0)
#define _DBG_LOCK_DESTROY(l) \
do { \
- MT_Lock * volatile _p; \
- /* save a copy for statistical purposes */ \
- _p = GDKmalloc(sizeof(MT_Lock)); \
- memcpy(_p, l, sizeof(MT_Lock)); \
- while (ATOMIC_TAS(GDKlocklistlock, dummy, "") != 0) \
- ; \
- _p->next = GDKlocklist; \
- GDKlocklist = _p; \
- for (_p = GDKlocklist; _p; _p = _p->next) \
- if (_p->next == (l)) { \
- _p->next = (l)->next; \
- break; \
- } \
- ATOMIC_CLEAR(GDKlocklistlock, dummy, ""); \
+ /* if name starts with "sa_" don't link in GDKlocklist */ \
+ /* since the lock is in memory that is governed by the */ \
+ /* SQL storage allocator, and hence we have no control */ \
+ /* over when the lock is destroyed and the memory freed */ \
+ if (strncmp((l)->name, "sa_", 3) != 0) { \
+ MT_Lock * volatile _p; \
+ /* save a copy for statistical purposes */ \
+ _p = GDKmalloc(sizeof(MT_Lock)); \
+ memcpy(_p, l, sizeof(MT_Lock)); \
+ while (ATOMIC_TAS(GDKlocklistlock, dummy, "") != 0) \
+ ; \
+ _p->next = GDKlocklist; \
+ GDKlocklist = _p; \
+ for (_p = GDKlocklist; _p; _p = _p->next) \
+ if (_p->next == (l)) { \
+ _p->next = (l)->next; \
+ break; \
+ } \
+ ATOMIC_CLEAR(GDKlocklistlock, dummy, ""); \
+ } \
} while (0)
#else
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -42,7 +42,7 @@ list_create(fdestroy destroy)
l->cnt = 0;
l->expected_cnt = 0;
l->ht = NULL;
- MT_lock_init(&l->ht_lock, "ht_lock");
+ MT_lock_init(&l->ht_lock, "sa_ht_lock");
return l;
}
@@ -56,7 +56,7 @@ sa_list(sql_allocator *sa)
l->h = l->t = NULL;
l->cnt = 0;
l->ht = NULL;
- MT_lock_init(&l->ht_lock, "ht_lock");
+ MT_lock_init(&l->ht_lock, "sa_ht_lock");
return l;
}
@@ -70,7 +70,7 @@ list_new(sql_allocator *sa, fdestroy des
l->h = l->t = NULL;
l->cnt = 0;
l->ht = NULL;
- MT_lock_init(&l->ht_lock, "ht_lock");
+ MT_lock_init(&l->ht_lock, "sa_ht_lock");
return l;
}
@@ -108,6 +108,7 @@ list_destroy(list *l)
if (l) {
node *n = l->h;
+ MT_lock_destroy(&l->ht_lock);
while (n && (l->destroy|| !l->sa)) {
node *t = n;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list