diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-02-12 13:00:49 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-02-12 13:00:49 +1100 |
commit | 04ec3d021d2f8b08b69d3ea5d0f243f468c71f2e (patch) | |
tree | 1c37b5ac7ea7373b76012b5a40097b80454968a7 /src | |
parent | 922d15b5f006ab6b9a482a4e83d52eb5a29ca889 (diff) | |
download | mongo-04ec3d021d2f8b08b69d3ea5d0f243f468c71f2e.tar.gz |
Move server thread waits to the beginning of their loops: check that we're still running before waiting. This makes more sense to me, but also fixes a problem introduced recently where the checkpoint server could hang on shutdown if the signal from the closing thread got lost.
Diffstat (limited to 'src')
-rw-r--r-- | src/conn/conn_ckpt.c | 16 | ||||
-rw-r--r-- | src/conn/conn_stat.c | 6 | ||||
-rw-r--r-- | src/conn/conn_sweep.c | 1 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c index f38628617dd..6eb134c1765 100644 --- a/src/conn/conn_ckpt.c +++ b/src/conn/conn_ckpt.c @@ -83,6 +83,14 @@ __ckpt_server(void *arg) while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_CHECKPOINT)) { + /* + * Wait... + * NOTE: If the user only configured logsize, then usecs + * will be 0 and this wait won't return until signalled. + */ + WT_ERR( + __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs)); + /* Checkpoint the database. */ WT_ERR(wt_session->checkpoint(wt_session, conn->ckpt_config)); @@ -99,14 +107,6 @@ __ckpt_server(void *arg) */ WT_ERR(__wt_cond_wait(session, conn->ckpt_cond, 1)); } - - /* - * Wait... - * NOTE: If the user only configured logsize, then usecs - * will be 0 and this wait won't return until signalled. - */ - WT_ERR( - __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs)); } if (0) { diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c index 2d8395c0517..be2172ea8d8 100644 --- a/src/conn/conn_stat.c +++ b/src/conn/conn_stat.c @@ -406,12 +406,12 @@ __statlog_server(void *arg) while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_STATISTICS)) { - if (!FLD_ISSET(conn->stat_flags, WT_CONN_STAT_NONE)) - WT_ERR(__statlog_log_one(session, &path, &tmp)); - /* Wait until the next event. */ WT_ERR( __wt_cond_wait(session, conn->stat_cond, conn->stat_usecs)); + + if (!FLD_ISSET(conn->stat_flags, WT_CONN_STAT_NONE)) + WT_ERR(__statlog_log_one(session, &path, &tmp)); } if (0) { diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c index a5bd8e1343c..5145583fc7d 100644 --- a/src/conn/conn_sweep.c +++ b/src/conn/conn_sweep.c @@ -118,7 +118,6 @@ __sweep_server(void *arg) */ while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_SWEEP)) { - /* Wait until the next event. */ WT_ERR(__wt_cond_wait(session, conn->sweep_cond, WT_DHANDLE_SWEEP_PERIOD * WT_MILLION)); |