s4:librpc/rpc: don't do async requests if gensec doesn't support async replies (bug...
authorStefan Metzmacher <metze@samba.org>
Fri, 24 Aug 2012 06:29:21 +0000 (08:29 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 24 Aug 2012 23:39:41 +0000 (01:39 +0200)
metze

source4/librpc/rpc/dcerpc.c

index 331a6b018ef854e4667e00dab44b8d49de9ee8a2..4440395e94ecf6e95759b1eb087e80695f156294 100644 (file)
@@ -60,6 +60,7 @@ struct rpc_request {
        uint16_t opnum;
        DATA_BLOB request_data;
        bool ignore_timeout;
+       bool wait_for_sync;
 
        /* use by the ndr level async recv call */
        struct {
@@ -1535,6 +1536,7 @@ static void dcerpc_ship_next_request(struct dcecli_connection *c)
        bool first_packet = true;
        size_t sig_size = 0;
        bool need_async = false;
+       bool can_async = true;
 
        req = c->request_queue;
        if (req == NULL) {
@@ -1548,6 +1550,32 @@ static void dcerpc_ship_next_request(struct dcecli_connection *c)
                need_async = true;
        }
 
+       if (c->security_state.auth_info &&
+           c->security_state.generic_state)
+       {
+               struct gensec_security *gensec = c->security_state.generic_state;
+
+               switch (c->security_state.auth_info->auth_level) {
+               case DCERPC_AUTH_LEVEL_PRIVACY:
+               case DCERPC_AUTH_LEVEL_INTEGRITY:
+                       can_async = gensec_have_feature(gensec,
+                                               GENSEC_FEATURE_ASYNC_REPLIES);
+                       break;
+               case DCERPC_AUTH_LEVEL_CONNECT:
+               case DCERPC_AUTH_LEVEL_NONE:
+                       can_async = true;
+                       break;
+               default:
+                       can_async = false;
+                       break;
+               }
+       }
+
+       if (need_async && !can_async) {
+               req->wait_for_sync = true;
+               return;
+       }
+
        DLIST_REMOVE(c->request_queue, req);
        DLIST_ADD(c->pending, req);
        req->state = RPC_REQUEST_PENDING;
@@ -1662,6 +1690,10 @@ static void dcerpc_schedule_io_trigger(struct dcecli_connection *c)
                return;
        }
 
+       if (c->request_queue->wait_for_sync && c->pending) {
+               return;
+       }
+
        if (c->io_trigger_pending) {
                return;
        }