[ctxt] refactor + close the logger fd on freeing
This commit is contained in:
parent
6b939e44ee
commit
e349a336af
|
@ -68,14 +68,15 @@ void ax__ctxt_init(struct ax_ctxt* ax, struct rgn* init_rgn)
|
||||||
ASSERT(ax->bac != NULL, "backend wasn't initialized");
|
ASSERT(ax->bac != NULL, "backend wasn't initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shutdown(struct msgq* mq, pthread_t thid);
|
||||||
|
|
||||||
void ax__ctxt_cleanup(struct ax_ctxt* ax)
|
void ax__ctxt_cleanup(struct ax_ctxt* ax)
|
||||||
{
|
{
|
||||||
struct msgq* bac_mq = ax__backend_msgq(ax->bac);
|
shutdown(ax__backend_msgq(ax->bac), ax->bac_thid);
|
||||||
msgq_begin_send_typed(bac_mq, ax_msg_shutdown);
|
|
||||||
msgq_end_send(bac_mq);
|
if (ax->log_auto_close) {
|
||||||
ax_log(ax, "waiting for backend shutdown.");
|
fclose(ax->log_out);
|
||||||
pthread_join(ax->bac_thid, NULL);
|
}
|
||||||
ax_log(ax, "backend shutdown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
@ -258,3 +259,10 @@ cleanup:
|
||||||
rgn_cleanup(bac_rgn);
|
rgn_cleanup(bac_rgn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shutdown(struct msgq* mq, pthread_t thid)
|
||||||
|
{
|
||||||
|
(void) msgq_begin_send_typed(mq, ax_msg_shutdown);
|
||||||
|
msgq_end_send(mq);
|
||||||
|
pthread_join(thid, NULL);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue