Changeset: 3d0f45933e8a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3d0f45933e8a Modified Files: tools/merovingian/daemon/forkmserver.c Branch: Dec2023 Log Message:
Keep the lock a bit longer so that values don't get changed while we're (not) looking. diffs (71 lines): diff --git a/tools/merovingian/daemon/forkmserver.c b/tools/merovingian/daemon/forkmserver.c --- a/tools/merovingian/daemon/forkmserver.c +++ b/tools/merovingian/daemon/forkmserver.c @@ -723,7 +723,6 @@ forkMserver(const char *database, sabdb* (void) fcntl(pfdo[0], F_SETFD, FD_CLOEXEC); (void) fcntl(pfde[0], F_SETFD, FD_CLOEXEC); #endif - pthread_mutex_unlock(&_mero_topdp_lock); while (argv[freec] != NULL) { free(argv[freec++]); @@ -735,6 +734,8 @@ forkMserver(const char *database, sabdb* * and if it hangs, we're just doomed, with the drawback that we * completely kill the functionality of monetdbd too */ do { + pthread_mutex_unlock(&_mero_topdp_lock); + /* give the database a break */ sleep_ms(500); @@ -756,12 +757,7 @@ forkMserver(const char *database, sabdb* * waited for), the pid will have been set to -1, so check * that. */ pthread_mutex_lock(&_mero_topdp_lock); - if (dp->pid == -1) { - pthread_mutex_unlock(&_mero_topdp_lock); - break; - } - pthread_mutex_unlock(&_mero_topdp_lock); - } while ((*stats)->state != SABdbRunning); + } while (dp->pid != -1 && (*stats)->state != SABdbRunning); /* check if the SQL scenario was loaded */ if (dp->pid != -1 && (*stats)->state == SABdbRunning && @@ -777,14 +773,18 @@ forkMserver(const char *database, sabdb* if (scen == NULL) { /* we don't know what it's doing, but we don't like it * any case, so kill it */ - (void) terminateProcess(dp->dbname, dp->pid, MERODB); + pid_t pid = dp->pid; + pthread_mutex_unlock(&_mero_topdp_lock); + (void) terminateProcess(dp->dbname, pid, MERODB); msab_freeStatus(stats); pthread_mutex_unlock(&dp->fork_lock); return(newErr("database '%s' did not initialise the sql " "scenario", database)); } } else if (dp->pid != -1) { - (void) terminateProcess(dp->dbname, dp->pid, MERODB); + pid_t pid = dp->pid; + pthread_mutex_unlock(&_mero_topdp_lock); + (void) terminateProcess(dp->dbname, pid, MERODB); msab_freeStatus(stats); pthread_mutex_unlock(&dp->fork_lock); return(newErr( @@ -796,6 +796,7 @@ forkMserver(const char *database, sabdb* if (dp->pid == -1) { state = (*stats)->state; + pthread_mutex_unlock(&_mero_topdp_lock); pthread_mutex_unlock(&dp->fork_lock); /* starting failed */ @@ -837,6 +838,7 @@ forkMserver(const char *database, sabdb* } } + pthread_mutex_unlock(&_mero_topdp_lock); pthread_mutex_unlock(&dp->fork_lock); if ((*stats)->locked) { _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org