Prechádzať zdrojové kódy

Plumb pollset_set through setup pipeline

Craig Tiller 10 rokov pred
rodič
commit
928cd7710f

+ 3 - 4
src/core/channel/client_channel.c

@@ -212,6 +212,7 @@ static void cc_start_transport_op(grpc_call_element *elem,
           if (!chand->transport_setup_initiated) {
           if (!chand->transport_setup_initiated) {
             chand->transport_setup_initiated = 1;
             chand->transport_setup_initiated = 1;
             initiate_transport_setup = 1;
             initiate_transport_setup = 1;
+            grpc_pollset_set_init(&chand->waiting_pollsets);
           }
           }
           /* add this call to the waiting set to be resumed once we have a child
           /* add this call to the waiting set to be resumed once we have a child
              channel stack, growing the waiting set if needed */
              channel stack, growing the waiting set if needed */
@@ -222,9 +223,6 @@ static void cc_start_transport_op(grpc_call_element *elem,
                 chand->waiting_children,
                 chand->waiting_children,
                 chand->waiting_child_capacity * sizeof(call_data *));
                 chand->waiting_child_capacity * sizeof(call_data *));
           }
           }
-          if (chand->waiting_child_count == 0) {
-            grpc_pollset_set_init(&chand->waiting_pollsets);
-          }
           grpc_pollset_set_add_pollset(&chand->waiting_pollsets, op->bind_pollset);
           grpc_pollset_set_add_pollset(&chand->waiting_pollsets, op->bind_pollset);
           calld->s.waiting_op = *op;
           calld->s.waiting_op = *op;
           chand->waiting_children[chand->waiting_child_count++] = calld;
           chand->waiting_children[chand->waiting_child_count++] = calld;
@@ -232,7 +230,8 @@ static void cc_start_transport_op(grpc_call_element *elem,
 
 
           /* finally initiate transport setup if needed */
           /* finally initiate transport setup if needed */
           if (initiate_transport_setup) {
           if (initiate_transport_setup) {
-            grpc_transport_setup_initiate(chand->transport_setup);
+            grpc_transport_setup_initiate(chand->transport_setup,
+                                          &chand->waiting_pollsets);
           }
           }
         }
         }
       }
       }

+ 4 - 1
src/core/channel/client_setup.c

@@ -61,6 +61,7 @@ struct grpc_client_setup {
 struct grpc_client_setup_request {
 struct grpc_client_setup_request {
   /* pointer back to the setup object */
   /* pointer back to the setup object */
   grpc_client_setup *setup;
   grpc_client_setup *setup;
+  grpc_pollset_set *interested_parties;
   gpr_timespec deadline;
   gpr_timespec deadline;
 };
 };
 
 
@@ -77,12 +78,14 @@ static void destroy_setup(grpc_client_setup *s) {
 }
 }
 
 
 /* initiate handshaking */
 /* initiate handshaking */
-static void setup_initiate(grpc_transport_setup *sp) {
+static void setup_initiate(grpc_transport_setup *sp,
+                           grpc_pollset_set *interested_parties) {
   grpc_client_setup *s = (grpc_client_setup *)sp;
   grpc_client_setup *s = (grpc_client_setup *)sp;
   grpc_client_setup_request *r = gpr_malloc(sizeof(grpc_client_setup_request));
   grpc_client_setup_request *r = gpr_malloc(sizeof(grpc_client_setup_request));
   int in_alarm = 0;
   int in_alarm = 0;
 
 
   r->setup = s;
   r->setup = s;
+  r->interested_parties = interested_parties;
   /* TODO(klempner): Actually set a deadline */
   /* TODO(klempner): Actually set a deadline */
   r->deadline = gpr_inf_future;
   r->deadline = gpr_inf_future;
 
 

+ 3 - 2
src/core/transport/transport.c

@@ -82,8 +82,9 @@ void grpc_transport_setup_cancel(grpc_transport_setup *setup) {
   setup->vtable->cancel(setup);
   setup->vtable->cancel(setup);
 }
 }
 
 
-void grpc_transport_setup_initiate(grpc_transport_setup *setup) {
-  setup->vtable->initiate(setup);
+void grpc_transport_setup_initiate(grpc_transport_setup *setup,
+                                   grpc_pollset_set *interested_parties) {
+  setup->vtable->initiate(setup, interested_parties);
 }
 }
 
 
 void grpc_transport_op_finish_with_failure(grpc_transport_op *op) {
 void grpc_transport_op_finish_with_failure(grpc_transport_op *op) {

+ 5 - 2
src/core/transport/transport.h

@@ -37,6 +37,7 @@
 #include <stddef.h>
 #include <stddef.h>
 
 
 #include "src/core/iomgr/pollset.h"
 #include "src/core/iomgr/pollset.h"
+#include "src/core/iomgr/pollset_set.h"
 #include "src/core/transport/stream_op.h"
 #include "src/core/transport/stream_op.h"
 
 
 /* forward declarations */
 /* forward declarations */
@@ -193,7 +194,8 @@ typedef struct grpc_transport_setup grpc_transport_setup;
 typedef struct grpc_transport_setup_vtable grpc_transport_setup_vtable;
 typedef struct grpc_transport_setup_vtable grpc_transport_setup_vtable;
 
 
 struct grpc_transport_setup_vtable {
 struct grpc_transport_setup_vtable {
-  void (*initiate)(grpc_transport_setup *setup);
+  void (*initiate)(grpc_transport_setup *setup,
+                   grpc_pollset_set *interested_parties);
   void (*cancel)(grpc_transport_setup *setup);
   void (*cancel)(grpc_transport_setup *setup);
 };
 };
 
 
@@ -209,7 +211,8 @@ struct grpc_transport_setup {
    setup construction time.
    setup construction time.
    This *may* be implemented as a no-op if the setup process monitors something
    This *may* be implemented as a no-op if the setup process monitors something
    continuously. */
    continuously. */
-void grpc_transport_setup_initiate(grpc_transport_setup *setup);
+void grpc_transport_setup_initiate(grpc_transport_setup *setup,
+                                   grpc_pollset_set *interested_parties);
 /* Cancel transport setup. After this returns, no new transports should be
 /* Cancel transport setup. After this returns, no new transports should be
    created, and all pending transport setup callbacks should be completed.
    created, and all pending transport setup callbacks should be completed.
    After this call completes, setup should be considered invalid (this can be
    After this call completes, setup should be considered invalid (this can be