With the latest patches we defer messages to a messaging_context's default
context, the one that it was created with. This is another incarnation of
085542fc93b3 (I believe): messaging contexts can outlive their tevent contexts.
In this case, the tevent_schedule_immediate(msg_ctx->event_ctx) has nothing to
schedule on and will crash. This patch uses the fact that tevent_fd's can
outlive their event_contexts. When the tevent_context dies, all tevent_fd's
will get their flags set to 0. The tevent_handles in messages_dgm_ref always
have TEVENT_FD_READ set, so a 0 flags field indicates the tevent_context has
died.
Signed-off-by: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Oct 5 03:51:43 CEST 2016 on sn-devel-144
* that grabs the fd's will get them.
*/
for (r = refs; r != NULL; r = next) {
+ uint16_t flags;
+
next = r->next;
+
+ flags = tevent_fd_get_flags(r->tevent_handle);
+ if (flags == 0) {
+ /*
+ * r's tevent_context has died.
+ */
+ continue;
+ }
+
r->recv_cb(ev, msg, msg_len, fds, num_fds,
r->recv_cb_private_data);
}