Changeset: 766a25c59de0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/766a25c59de0 Modified Files: gdk/gdk_logger.c Branch: Dec2023 Log Message:
Move locking out of do_flush_range_cleanup(). This way, the caller can keep the lock while keeping a pointer to the logged_range, especially inside log_tflush. diffs (91 lines): diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -2335,7 +2335,6 @@ log_new(int debug, const char *fn, const static logged_range * do_flush_range_cleanup(logger *lg) { - rotation_lock(lg); logged_range *frange = lg->flush_ranges; logged_range *first = frange; @@ -2345,7 +2344,6 @@ do_flush_range_cleanup(logger *lg) frange = frange->next; } if (first == frange) { - rotation_unlock(lg); return first; } @@ -2361,7 +2359,6 @@ do_flush_range_cleanup(logger *lg) frange->output_log = NULL; } } - rotation_unlock(lg); return flast; } @@ -2535,9 +2532,9 @@ log_activate(logger *lg) flush_cleanup = true; do_rotate(lg); } - rotation_unlock(lg); if (flush_cleanup) (void) do_flush_range_cleanup(lg); + rotation_unlock(lg); return res; } @@ -3162,15 +3159,16 @@ log_tflush(logger *lg, ulng file_id, uln if (log_open_output(lg) != GDK_SUCCEED) GDKfatal("Could not create new log file\n"); /* TODO: does not have to be fatal (yet) */ do_rotate(lg); - rotation_unlock(lg); (void) do_flush_range_cleanup(lg); assert(lg->flush_ranges == lg->current); + rotation_unlock(lg); return log_commit(lg, p, NULL, 0); } if (LOG_DISABLED(lg)) return GDK_SUCCEED; + rotation_lock(lg); logged_range *frange = do_flush_range_cleanup(lg); while (frange->next && frange->id < file_id) { @@ -3192,22 +3190,20 @@ log_tflush(logger *lg, ulng file_id, uln /* else somebody else has flushed our log file */ if (ATOMIC_DEC(&frange->refcount) == 1 && !LOG_DISABLED(lg)) { - rotation_lock(lg); if (frange != lg->current && frange->output_log) { close_stream(frange->output_log); frange->output_log = NULL; } - rotation_unlock(lg); } if (ATOMIC_DEC(&lg->nr_flushers) == 0) { /* I am the last flusher * if present, * wake up the exclusive flusher in log_tstart */ - rotation_lock(lg); + /* rotation_lock is still being held */ MT_cond_signal(&lg->excl_flush_cv); - rotation_unlock(lg); } + rotation_unlock(lg); return GDK_SUCCEED; } @@ -3381,8 +3377,8 @@ log_tstart(logger *lg, bool flushnow, ul GDKfatal("Could not create new log file\n"); /* TODO: does not have to be fatal (yet) */ } do_rotate(lg); + (void) do_flush_range_cleanup(lg); rotation_unlock(lg); - (void) do_flush_range_cleanup(lg); if (lg->saved_id + 1 < lg->id) log_flush(lg, (1ULL << 63)); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org