When a slave is shut down, it crashes, because we cannot call tdb_down without tdb_up, and that obviously only happens on a master. Also, plug a problem inside rtdb_fini (needs a better fix but should do for now). Signed-off-by: Pete Zaitcev <zaitcev@xxxxxxxxxx> --- server/metarep.c | 9 ++++++++- server/server.c | 11 +++-------- 2 files changed, 11 insertions(+), 9 deletions(-) commit dd6ed2529efa71902f7ac1958f01a2541b4f9133 Author: Pete Zaitcev <zaitcev@xxxxxxxxx> Date: Thu Aug 12 12:27:48 2010 -0600 Crash on tdb_down if slave. diff --git a/server/metarep.c b/server/metarep.c index d3eec49..e13b13f 100644 --- a/server/metarep.c +++ b/server/metarep.c @@ -1240,6 +1240,13 @@ int rtdb_restart(struct tablerep *rtdb, bool we_are_master) void rtdb_fini(struct tablerep *rtdb) { __rtdb_fini(rtdb); - tdb_fini(&rtdb->tdb); + /* + * This check is ewwww, but unfortunately there's potentially a gap + * between DB going master and us bringing up the environment. + * If we condition the tdb_fini on DB status, we'll end crashing + * if the server terminates during the gap. + */ + if (rtdb->tdb.env) + tdb_fini(&rtdb->tdb); } diff --git a/server/server.c b/server/server.c index 8859847..1f8164b 100644 --- a/server/server.c +++ b/server/server.c @@ -2326,18 +2326,13 @@ int main (int argc, char *argv[]) applog(LOG_INFO, "shutting down"); rc = 0; - + if (tabled_srv.state_tdb == ST_TDB_MASTER) + tdb_down(&tdbrep.tdb); cld_end(); err_cld_session: /* net_close(); */ err_out_net: - if (tabled_srv.state_tdb == ST_TDB_MASTER || - tabled_srv.state_tdb == ST_TDB_SLAVE) { - tdb_down(&tdbrep.tdb); - rtdb_fini(&tdbrep); - } else if (tabled_srv.state_tdb == ST_TDB_OPEN) { - rtdb_fini(&tdbrep); - } + rtdb_fini(&tdbrep); err_rtdb: event_del(&tabled_srv.pevt); err_pevt: -- To unsubscribe from this list: send the line "unsubscribe hail-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html