[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");
|
||||
}
|
||||
|
||||
static void shutdown(struct msgq* mq, pthread_t thid);
|
||||
|
||||
void ax__ctxt_cleanup(struct ax_ctxt* ax)
|
||||
{
|
||||
struct msgq* bac_mq = ax__backend_msgq(ax->bac);
|
||||
msgq_begin_send_typed(bac_mq, ax_msg_shutdown);
|
||||
msgq_end_send(bac_mq);
|
||||
ax_log(ax, "waiting for backend shutdown.");
|
||||
pthread_join(ax->bac_thid, NULL);
|
||||
ax_log(ax, "backend shutdown");
|
||||
shutdown(ax__backend_msgq(ax->bac), ax->bac_thid);
|
||||
|
||||
if (ax->log_auto_close) {
|
||||
fclose(ax->log_out);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
@ -258,3 +259,10 @@ cleanup:
|
|||
rgn_cleanup(bac_rgn);
|
||||
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