summaryrefslogtreecommitdiff
path: root/lib/tevent/tevent.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-03-12 09:51:33 +0100
committerStefan Metzmacher <metze@samba.org>2009-03-12 12:14:18 +0100
commit06f88fe7a2f9ce93f8cdbec0910cc8471c12b1c3 (patch)
tree7633f8ab8db558ee6f1b449e6e5f58db27397e54 /lib/tevent/tevent.c
parentbd0f14c1d782b6afe9455e61819caeb2d480af1e (diff)
downloadsamba-06f88fe7a2f9ce93f8cdbec0910cc8471c12b1c3.tar.gz
samba-06f88fe7a2f9ce93f8cdbec0910cc8471c12b1c3.tar.bz2
samba-06f88fe7a2f9ce93f8cdbec0910cc8471c12b1c3.zip
tevent: don't allow nested tevent_loop_once() anymore
Incompatible caller should use tevent_loop_allow_nesting() function. metze
Diffstat (limited to 'lib/tevent/tevent.c')
-rw-r--r--lib/tevent/tevent.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index d7db303d87..a6bac6097d 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -59,6 +59,7 @@
*/
#include "replace.h"
#include "system/filesys.h"
+#define TEVENT_DEPRECATED 1
#include "tevent.h"
#include "tevent_internal.h"
#include "tevent_util.h"
@@ -368,12 +369,46 @@ struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
handler_name, location);
}
+void tevent_loop_allow_nesting(struct tevent_context *ev)
+{
+ ev->nesting.allowed = true;
+}
+
+static void tevent_abort_nesting(struct tevent_context *ev, const char *location)
+{
+ const char *reason;
+
+ reason = talloc_asprintf(NULL, "tevent_loop_once() nesting at %s",
+ location);
+ if (!reason) {
+ reason = "tevent_loop_once() nesting";
+ }
+
+ tevent_abort(ev, reason);
+}
+
/*
do a single event loop using the events defined in ev
*/
int _tevent_loop_once(struct tevent_context *ev, const char *location)
{
- return ev->ops->loop_once(ev, location);
+ int ret;
+
+ ev->nesting.level++;
+
+ if (ev->nesting.level > 1) {
+ if (!ev->nesting.allowed) {
+ tevent_abort_nesting(ev, location);
+ errno = ELOOP;
+ return -1;
+ }
+ }
+
+ ret = ev->ops->loop_once(ev, location);
+
+ ev->nesting.level--;
+
+ return ret;
}
/*