dbwrap: add enum dbwrap_req_state
authorRalph Boehme <slow@samba.org>
Tue, 10 Jan 2017 13:22:21 +0000 (14:22 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 18 Apr 2017 20:54:16 +0000 (22:54 +0200)
This will be used by async dwrap_parse_send() as an out argument, giving
the caller an indication about the state of the request.

This is can be useful for the caller if it is a sync function and sends
multiple async dbwrap requests. As it's a sync function it won't return
to the main tevent event loop and so the async dbwrap recv function are
not called.

As a result the function may deadlock: our receive queue may already be
full with results from a peer, the peer might be blocked in his send
queue (because we're not receiving), the peer therefor doesn't read from
his receive queue so our send queue will block as well.

To inform the caller of this situation "send queue full" we return this
state information to the caller of the dbwrap send function.

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

index 6b77236c530843cbf82de074c016ae118807bd3a..936e66247d762b7af05995e729ab3f30a684eb78 100644 (file)
@@ -43,6 +43,29 @@ enum dbwrap_lock_order {
 #define DBWRAP_FLAG_NONE                     0x0000000000000000ULL
 #define DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS 0x0000000000000001ULL
 
+enum dbwrap_req_state {
+       /**
+        * We are creating the request
+        */
+       DBWRAP_REQ_INIT,
+       /**
+        * The request is queued and waiting to be dispatched
+        */
+       DBWRAP_REQ_QUEUED,
+       /**
+        * We are waiting to receive the reply
+        */
+       DBWRAP_REQ_DISPATCHED,
+       /**
+        * The request is finished
+        */
+       DBWRAP_REQ_DONE,
+       /**
+        * The request errored out
+        */
+       DBWRAP_REQ_ERROR
+};
+
 /* The following definitions come from lib/dbwrap.c  */
 
 TDB_DATA dbwrap_record_get_key(const struct db_record *rec);