Skip to content

Commit e750f1c

Browse files
committed
Message event loop tweaks
Stop the event source before unregistering it. Unregister the event loop before closing the journal. Unset the watch file descriptor when closing the parent journal. Assert the file descriptor of incoming events has the same number as the one on creation time (it might however still point to a differnt file).
1 parent 8ec7067 commit e750f1c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/netlog/netlog-manager.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ static int manager_journal_event_handler(sd_event_source *event, int fd, uint32_
304304
Manager *m = userp;
305305
int r;
306306

307+
assert(m);
308+
assert(m->journal);
309+
assert(m->journal_watch_fd == fd);
310+
307311
if (revents & EPOLLHUP) {
308312
log_debug("Received HUP");
309313
return 0;
@@ -335,6 +339,7 @@ static void close_journal_input(Manager *m) {
335339

336340
sd_journal_close(m->journal);
337341
m->journal = NULL;
342+
m->journal_watch_fd = -1;
338343
}
339344
}
340345

@@ -464,14 +469,13 @@ void manager_disconnect(Manager *m) {
464469

465470
m->resolve_query = sd_resolve_query_unref(m->resolve_query);
466471

467-
close_journal_input(m);
468-
469472
manager_close_network_socket(m);
470473

471474
dtls_disconnect(m->dtls);
472475
tls_disconnect(m->tls);
473476

474-
m->event_journal_input = sd_event_source_unref(m->event_journal_input);
477+
m->event_journal_input = sd_event_source_disable_unref(m->event_journal_input);
478+
close_journal_input(m);
475479

476480
sd_notifyf(false, "STATUS=Idle.");
477481
}

0 commit comments

Comments
 (0)