Changeset: dbd7e5d89c43 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dbd7e5d89c43
Modified Files:
        gdk/gdk.h
        gdk/gdk_logger.c
Branch: default
Log Message:

Fix some data races.


diffs (44 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -798,8 +798,9 @@ typedef struct BAT {
        bool
         batTransient:1,        /* should the BAT persist on disk? */
         batCopiedtodisk:1,     /* once written */
-        batDirtyflushed:1,     /* was dirty before commit started? */
         batDirtydesc:1;        /* bat descriptor dirty marker */
+       /* not part of bitfields since not in BATiter */
+       bool batDirtyflushed;   /* was dirty before commit started? */
        uint16_t selcnt;        /* how often used in equi select without hash */
        uint16_t unused;        /* value=0 for now (sneakily used by mat.c) */
        int batSharecnt;        /* incoming view count */
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2272,11 +2272,14 @@ logger_flush(logger *lg, ulng ts)
        }
        if (lg->saved_id >= lid)
                return GDK_SUCCEED;
-       if (lg->saved_id+1 >= lg->id) /* logger should first release the file */
+       MT_lock_set(&lg->rotation_lock);
+       ulng lgid = lg->id;
+       MT_lock_unset(&lg->rotation_lock);
+       if (lg->saved_id+1 >= lgid) /* logger should first release the file */
                return GDK_SUCCEED;
        log_return res = LOG_OK;
        while(lg->saved_id < lid && res == LOG_OK) {
-               if (lg->saved_id >= lg->id)
+               if (lg->saved_id >= lgid)
                        break;
                if (!lg->input_log) {
                        char *filename;
@@ -3075,7 +3078,9 @@ log_tstart(logger *lg, bool flushnow, ul
                if (flushnow) {
                        while (lg->saved_id+1 < lg->id) {
                                logger_unlock(lg);
+                               MT_lock_unset(&lg->rotation_lock);
                                logger_flush(lg, (1ULL<<63));
+                               MT_lock_set(&lg->rotation_lock);
                                logger_lock(lg);
                        }
                        lg->flushnow = flushnow;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to