messaging: Avoid crashes
authorVolker Lendecke <vl@samba.org>
Fri, 30 Sep 2016 13:42:40 +0000 (06:42 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 5 Oct 2016 01:51:43 +0000 (03:51 +0200)
commit23e77c56197d3db4271392ce1993930239e683be
treed6aab55bc70c6711be8388dc1f6680ebee343135
parent4ce599dcd2f5975df52b4392dc8a8e87b57a3f80
messaging: Avoid crashes

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
source3/lib/messages_dgm_ref.c