s3:messages: allow messaging_dgm_ref() to use wrapper tevent_context
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Mar 2018 13:48:46 +0000 (14:48 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 11 Jul 2018 21:04:24 +0000 (23:04 +0200)
This is only allowed if the raw tevent context is already registered.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/messages_dgm_ref.c

index fd170961746832edff80345934ae771004a6e3b3..12ff21ca6283a90c503f13996d054f9f208e48df 100644 (file)
@@ -55,18 +55,6 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 {
        struct msg_dgm_ref *result, *tmp_refs;
 
-       if (tevent_context_is_wrapper(ev)) {
-               /*
-                * This is really a programmer error!
-                *
-                * The main/raw tevent context should
-                * have been registered first!
-                */
-               DBG_ERR("Should not be used with a wrapper tevent context\n");
-               *err = EINVAL;
-               return NULL;
-       }
-
        result = talloc(mem_ctx, struct msg_dgm_ref);
        if (result == NULL) {
                *err = ENOMEM;
@@ -87,6 +75,18 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        if (refs == NULL) {
                int ret;
 
+               if (tevent_context_is_wrapper(ev)) {
+                       /*
+                        * This is really a programmer error!
+                        *
+                        * The main/raw tevent context should
+                        * have been registered first!
+                        */
+                       DBG_ERR("Should not be used with a wrapper tevent context\n");
+                       *err = EINVAL;
+                       return NULL;
+               }
+
                ret = messaging_dgm_init(ev, unique, socket_dir, lockfile_dir,
                                         msg_dgm_ref_recv, NULL);
                DBG_DEBUG("messaging_dgm_init returned %s\n", strerror(ret));