Changeset: e565d9ee0ee8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e565d9ee0ee8
Modified Files:
        gdk/gdk_bbp.c
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (87 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -290,10 +290,11 @@ BBPunlock(const char *nme)
 
 
 static void
-BBPinithash(void)
+BBPinithash(int j)
 {
        bat i = BBPsize;
 
+       assert(j >= 0 && j <= BBP_THREADMASK);
        for (BBP_mask = 1; (BBP_mask << 1) <= BBPlimit; BBP_mask <<= 1)
                ;
        BBP_hash = (bat *) GDKzalloc(BBP_mask * sizeof(bat));
@@ -314,8 +315,10 @@ BBPinithash(void)
                                BBP_insert(-i);
                        }
                } else {
-                       BBP_next(i) = BBP_free(i);
-                       BBP_free(i) = i;
+                       BBP_next(i) = BBP_free(j);
+                       BBP_free(j) = i;
+                       if (++j > BBP_THREADMASK)
+                               j = 0;
                }
        }
 }
@@ -326,7 +329,7 @@ BBPinithash(void)
  * BBPtrim, causing deadlock.
  */
 static void
-BBPextend(int buildhash)
+BBPextend(int idx, int buildhash)
 {
        BBP_notrim = MT_getpid();
 
@@ -350,7 +353,7 @@ BBPextend(int buildhash)
                BBP_hash = NULL;
                for (i = 0; i <= BBP_THREADMASK; i++)
                        BBP_free(i) = 0;
-               BBPinithash();
+               BBPinithash(idx);
        }
        BBP_notrim = 0;
 }
@@ -834,7 +837,7 @@ BBPreadEntries(FILE *fp, int *min_stamp,
                if ((bat) batid >= BBPsize) {
                        BBPsize = (bat) batid + 1;
                        if (BBPsize >= BBPlimit)
-                               BBPextend(FALSE);
+                               BBPextend(0, FALSE);
                }
                if (BBP_desc(bid) != NULL)
                        GDKfatal("BBPinit: duplicate entry in BBP.dir.");
@@ -1011,7 +1014,7 @@ BBPinit(void)
 
        bbpversion = BBPheader(fp, &BBPoid, &oidsize);
 
-       BBPextend(0);           /* allocate BBP records */
+       BBPextend(0, FALSE);            /* allocate BBP records */
        BBPsize = 1;
 
        BBPreadEntries(fp, &min_stamp, &max_stamp, oidsize, bbpversion);
@@ -1025,7 +1028,7 @@ BBPinit(void)
                BBPsetstamp(max_stamp - min_stamp);
        }
 
-       BBPinithash();
+       BBPinithash(0);
        BBP_notrim = 0;
 
        OIDbase(BBPoid);
@@ -1649,11 +1652,7 @@ BBPinsert(BATstore *bs)
                 * while we were waiting */
                if (BBP_free(idx) <= 0) {
                        if (BBPsize++ >= BBPlimit) {
-                               BBPextend(TRUE);
-                               /* it seems BBPextend could return and
-                                * still leaving BBP_free(idx) == 0 */
-                               if (BBP_free(idx) == 0)
-                                       BBP_free(idx) = BBPsize - 1;
+                               BBPextend(idx, TRUE);
                        } else {
                                BBP_free(idx) = BBPsize - 1;
                        }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to