Author: rhuijben
Date: Wed Nov 18 12:58:21 2015
New Revision: 1714990

URL: http://svn.apache.org/viewvc?rev=1714990&view=rev
Log:
Move the dirty pollset support to the io baton layer, instead of having
separate implementations on incoming and outgoing connections.

Rename the baton variables to 'io' in all cases to simplify usage.

This huge patch should not introduce any behavior changes.

* context.c
  (check_dirty_pollsets): Use value in baton.

* incoming.c
  (http1_enqueue_reponse,
   read_from_client,
   no_more_writes,
   serf__incoming_client_flush,
   write_to_client,
   serf_incoming_set_framing_type,
   serf_incoming_create2,
   serf_listener_create): Update usages.

* outgoing.c
  (serf__conn_update_pollset,
   serf__open_connections,
   no_more_writes,
   remove_connection,
   reset_connection,
   serf__connection_flush,
   write_to_connection,
   read_from_connection,
   process_connection,
   serf__process_connection,
   serf_connection_create,
   serf_connection_set_framing_type): Update usages.

* outgoing_request.c
  (serf_connection_request_create,
   priority_request_create): Update pollset using helper.

* protocols/fcgi_protocol.c
  (serf_fcgi_protocol_t): Store reference to io baton instead of to
    context and bool.
  (serf_fcgi__enqueue_frame,
   fcgi_write,
   serf__fcgi_protocol_init,
   serf__fcgi_protocol_init_server): Use io to abstract pollset usage.

* protocols/http2_protocol.c
  (serf_http2_protocol_t): Store reference to io baton.
  (serf__http2_protocol_init,
   serf__http2_protocol_init_server,
   serf_http2__enqueue_frame,
   http2_outgoing_read,
   http2_outgoing_write,
   http2_incoming_read,
   http2_incoming_write): Use io to abstract pollset usage.

* serf_private.h
  (serf_io_baton_t): Add two vars.
  (serf_io__set_pollset_dirty): Define helper 'method'.
  (serf_listener_t): Rename baton.
  (serf_incoming_t): Rename baton. Integrate variable.
  (serf_connection_t): Rename baton. Integrate variable.

Modified:
    serf/trunk/context.c
    serf/trunk/incoming.c
    serf/trunk/outgoing.c
    serf/trunk/outgoing_request.c
    serf/trunk/protocols/fcgi_protocol.c
    serf/trunk/protocols/http2_protocol.c
    serf/trunk/serf_private.h

Modified: serf/trunk/context.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/context.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/context.c (original)
+++ serf/trunk/context.c Wed Nov 18 12:58:21 2015
@@ -64,12 +64,12 @@ static apr_status_t check_dirty_pollsets
         apr_status_t status;
 
         /* if this connection isn't dirty, skip it. */
-        if (!conn->dirty_conn) {
+        if (!conn->io.dirty_conn) {
             continue;
         }
 
         /* reset this connection's flag before we update. */
-        conn->dirty_conn = 0;
+        conn->io.dirty_conn = false;
 
         if ((status = serf__conn_update_pollset(conn)) != APR_SUCCESS)
             return status;
@@ -79,18 +79,18 @@ static apr_status_t check_dirty_pollsets
         serf_incoming_t *incoming = GET_INCOMING(ctx, i);
         apr_status_t status;
 
-        if (!incoming->dirty_conn) {
+        if (!incoming->io.dirty_conn) {
             continue;
         }
 
-        incoming->dirty_conn = false;
+        incoming->io.dirty_conn = false;
 
         if ((status = serf__incoming_update_pollset(incoming)) != APR_SUCCESS)
             return status;
     }
 
     /* reset our context flag now */
-    ctx->dirty_pollset = 0;
+    ctx->dirty_pollset = false;
 
     return APR_SUCCESS;
 }

Modified: serf/trunk/incoming.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/incoming.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/incoming.c (original)
+++ serf/trunk/incoming.c Wed Nov 18 12:58:21 2015
@@ -149,8 +149,7 @@ static apr_status_t http1_enqueue_repons
                                                            bucket->allocator));
 
     /* Want write event */
-    request->incoming->dirty_conn = true;
-    request->incoming->ctx->dirty_pollset = true;
+    serf_io__set_pollset_dirty(&request->incoming->io);
 
     return APR_SUCCESS;
 }
@@ -372,7 +371,7 @@ static apr_status_t read_from_client(ser
         tdesc.desc.s = client->skt;
         tdesc.reqevents = client->reqevents;
         client->ctx->pollset_rm(client->ctx->pollset_baton,
-                                &tdesc, &client->baton);
+                                &tdesc, &client->io);
 
         client->seen_in_pollset |= APR_POLLHUP; /* No more events */
 
@@ -380,8 +379,7 @@ static apr_status_t read_from_client(ser
            and this listener will now be cleared from the context
            handlers dirty pollset support */
         client->skt = NULL;
-        client->dirty_conn = true;
-        client->ctx->dirty_pollset = true;
+        serf_io__set_pollset_dirty(&client->io);
     }
 
     status = client->closed(client, client->closed_baton, status,
@@ -455,8 +453,7 @@ static apr_status_t no_more_writes(serf_
   /* Update the pollset to know we don't want to write on this socket any
   * more.
   */
-  client->dirty_conn = true;
-  client->ctx->dirty_pollset = true;
+  serf_io__set_pollset_dirty(&client->io);
   return APR_SUCCESS;
 }
 
@@ -513,8 +510,7 @@ apr_status_t serf__incoming_client_flush
             end up in a CPU spin: socket wants something, but we
             don't have anything (and keep returning EAGAIN) */
             client->stop_writing = true;
-            client->dirty_conn = true;
-            client->ctx->dirty_pollset = true;
+            serf_io__set_pollset_dirty(&client->io);
 
             read_status = APR_EAGAIN;
         }
@@ -546,8 +542,7 @@ static apr_status_t write_to_client(serf
         return status;
 
     /* Probably nothing to write. Connection will check new requests */
-    client->dirty_conn = 1;
-    client->ctx->dirty_pollset = 1;
+    serf_io__set_pollset_dirty(&client->io);
 
     return APR_SUCCESS;
 }
@@ -565,8 +560,7 @@ void serf_incoming_set_framing_type(
     client->framing_type = framing_type;
 
     if (client->skt) {
-        client->dirty_conn = true;
-        client->ctx->dirty_pollset = true;
+        serf_io__set_pollset_dirty(&client->io);
         client->stop_writing = 0;
 
         /* Close down existing protocol */
@@ -732,13 +726,14 @@ apr_status_t serf_incoming_create2(
     ic->ctx = ctx;
     ic->pool = ic_pool;
     ic->allocator = serf_bucket_allocator_create(ic_pool, NULL, NULL);
-    ic->baton.type = SERF_IO_CLIENT;
-    ic->baton.u.client = ic;
+    ic->io.type = SERF_IO_CLIENT;
+    ic->io.u.client = ic;
+    ic->io.ctx = ctx;
+    ic->io.dirty_conn = false;
     ic->req_setup = req_setup;
     ic->req_setup_baton = req_setup_baton;
     ic->skt = insock;
 
-    ic->dirty_conn = false;
     ic->wait_for_connect = true;
     ic->vec_len = 0;
     /* Detect HTTP 1 or 2 via peek operation */
@@ -775,7 +770,7 @@ apr_status_t serf_incoming_create2(
     ic->config = config;
 
     rv = ctx->pollset_add(ctx->pollset_baton,
-                         &ic->desc, &ic->baton);
+                         &ic->desc, &ic->io);
 
     if (!rv) {
         apr_pool_cleanup_register(ic->pool, ic, incoming_cleanup,
@@ -806,8 +801,10 @@ apr_status_t serf_listener_create(
     serf_listener_t *l = apr_palloc(pool, sizeof(*l));
 
     l->ctx = ctx;
-    l->baton.type = SERF_IO_LISTENER;
-    l->baton.u.listener = l;
+    l->io.type = SERF_IO_LISTENER;
+    l->io.u.listener = l;
+    l->io.ctx = ctx;
+    l->io.dirty_conn = false;
     l->accept_func = accept;
     l->accept_baton = accept_baton;
 
@@ -853,7 +850,7 @@ apr_status_t serf_listener_create(
     l->desc.reqevents = APR_POLLIN;
 
     rv = ctx->pollset_add(ctx->pollset_baton,
-                            &l->desc, &l->baton);
+                            &l->desc, &l->io);
     if (rv) {
         apr_pool_destroy(l->pool);
         return rv;
@@ -909,7 +906,7 @@ apr_status_t serf__incoming_update_polls
     desc.reqevents = client->reqevents;
 
     status = ctx->pollset_rm(ctx->pollset_baton,
-                             &desc, &client->baton);
+                             &desc, &client->io);
     if (status && !APR_STATUS_IS_NOTFOUND(status))
         return status;
 
@@ -974,5 +971,5 @@ apr_status_t serf__incoming_update_polls
      * want to poll it for hangups and errors.
      */
     return ctx->pollset_add(ctx->pollset_baton,
-                            &desc, &client->baton);
+                            &desc, &client->io);
 }

Modified: serf/trunk/outgoing.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/outgoing.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/outgoing.c (original)
+++ serf/trunk/outgoing.c Wed Nov 18 12:58:21 2015
@@ -161,7 +161,7 @@ apr_status_t serf__conn_update_pollset(s
     desc.reqevents = conn->reqevents;
 
     status = ctx->pollset_rm(ctx->pollset_baton,
-                             &desc, &conn->baton);
+                             &desc, &conn->io);
     if (status && !APR_STATUS_IS_NOTFOUND(status))
         return status;
 
@@ -259,7 +259,7 @@ apr_status_t serf__conn_update_pollset(s
      * want to poll it for hangups and errors.
      */
     return ctx->pollset_add(ctx->pollset_baton,
-                            &desc, &conn->baton);
+                            &desc, &conn->io);
 }
 
 #ifdef SERF_DEBUG_BUCKET_USE
@@ -582,8 +582,7 @@ apr_status_t serf__open_connections(serf
             return status;
 
         /* Flag our pollset as dirty now that we have a new socket. */
-        conn->dirty_conn = 1;
-        ctx->dirty_pollset = 1;
+        serf_io__set_pollset_dirty(&conn->io);
 
         if (! conn->wait_for_connect) {
             status = connect_connection(conn);
@@ -609,8 +608,7 @@ static apr_status_t no_more_writes(serf_
     /* Update the pollset to know we don't want to write on this socket any
      * more.
      */
-    conn->dirty_conn = 1;
-    conn->ctx->dirty_pollset = 1;
+    serf_io__set_pollset_dirty(&conn->io);
     return APR_SUCCESS;
 }
 
@@ -644,7 +642,7 @@ static apr_status_t remove_connection(se
     desc.reqevents = conn->reqevents;
 
     return ctx->pollset_rm(ctx->pollset_baton,
-                           &desc, &conn->baton);
+                           &desc, &conn->io);
 }
 
 /* A socket was closed, inform the application. */
@@ -727,8 +725,7 @@ static apr_status_t reset_connection(ser
     /* Don't try to resume any writes */
     conn->vec_len = 0;
 
-    conn->dirty_conn = 1;
-    conn->ctx->dirty_pollset = 1;
+    serf_io__set_pollset_dirty(&conn->io);
     conn->state = SERF_CONN_INIT;
 
     conn->hit_eof = 0;
@@ -877,8 +874,7 @@ apr_status_t serf__connection_flush(serf
             end up in a CPU spin: socket wants something, but we
             don't have anything (and keep returning EAGAIN) */
             conn->stop_writing = 1;
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
+            serf_io__set_pollset_dirty(&conn->io);
 
             read_status = APR_EAGAIN;
         }
@@ -1021,8 +1017,7 @@ static apr_status_t write_to_connection(
             (conn->max_outstanding_requests &&
              REQS_IN_PROGRESS(conn) >= conn->max_outstanding_requests)) {
 
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
+            serf_io__set_pollset_dirty(&conn->io);
 
             /* backoff for now. */
             return APR_SUCCESS;
@@ -1037,8 +1032,7 @@ static apr_status_t write_to_connection(
              * Let's update the pollset so that we don't try to write to this
              * socket again.
              */
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
+            serf_io__set_pollset_dirty(&conn->io);
             return APR_SUCCESS;
         }
 
@@ -1129,8 +1123,7 @@ static apr_status_t read_from_connection
        there is some data to read. */
     if (conn->stop_writing) {
         conn->stop_writing = 0;
-        conn->dirty_conn = 1;
-        conn->ctx->dirty_pollset = 1;
+        serf_io__set_pollset_dirty(&conn->io);
     }
 
     /* assert: request != NULL */
@@ -1252,8 +1245,7 @@ static apr_status_t read_from_connection
                serf will not check for socket writability, so force this here.
              */
             if (request_or_data_pending(&request, conn) && !request) {
-                conn->dirty_conn = 1;
-                conn->ctx->dirty_pollset = 1;
+                serf_io__set_pollset_dirty(&conn->io);
             }
             status = APR_SUCCESS;
             goto error;
@@ -1301,8 +1293,7 @@ static apr_status_t read_from_connection
            requests on this connection, we should stop polling for READ events
            for now. */
         if (!conn->written_reqs && !conn->unwritten_reqs) {
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
+            serf_io__set_pollset_dirty(&conn->io);
         }
 
         /* This means that we're being advised that the connection is done. */
@@ -1328,8 +1319,7 @@ static apr_status_t read_from_connection
          * more. We are definitely done with this loop, too.
          */
         if (request == NULL || request->writing == SERF_WRITING_NONE) {
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
+            serf_io__set_pollset_dirty(&conn->io);
             status = APR_SUCCESS;
             goto error;
         }
@@ -1490,8 +1480,7 @@ static apr_status_t process_connection(s
             conn->wait_for_connect = FALSE;
 
             /* We are now connected. Socket is now usable */
-            conn->dirty_conn = TRUE;
-            conn->ctx->dirty_pollset = TRUE;
+            serf_io__set_pollset_dirty(&conn->io);
 
             if ((status = connect_connection(conn)) != APR_SUCCESS)
                 return status;
@@ -1517,7 +1506,7 @@ apr_status_t serf__process_connection(se
         tdesc.desc.s = conn->skt;
         tdesc.reqevents = conn->reqevents;
         ctx->pollset_rm(ctx->pollset_baton,
-                        &tdesc, &conn->baton);
+                        &tdesc, &conn->io);
         return conn->status;
     }
     /* apr_pollset_poll() can return a conn multiple times... */
@@ -1537,7 +1526,7 @@ apr_status_t serf__process_connection(se
             tdesc.desc.s = conn->skt;
             tdesc.reqevents = conn->reqevents;
             ctx->pollset_rm(ctx->pollset_baton,
-                            &tdesc, &conn->baton);
+                            &tdesc, &conn->io);
         }
         return conn->status;
     }
@@ -1568,8 +1557,10 @@ serf_connection_t *serf_connection_creat
     conn->stream = NULL;
     conn->ostream_head = NULL;
     conn->ostream_tail = NULL;
-    conn->baton.type = SERF_IO_CONN;
-    conn->baton.u.conn = conn;
+    conn->io.type = SERF_IO_CONN;
+    conn->io.u.conn = conn;
+    conn->io.ctx = ctx;
+    conn->io.dirty_conn = false;
     conn->hit_eof = 0;
     conn->state = SERF_CONN_INIT;
     conn->latency = -1; /* unknown */
@@ -1789,8 +1780,7 @@ void serf_connection_set_framing_type(
     conn->framing_type = framing_type;
 
     if (conn->skt) {
-        conn->dirty_conn = 1;
-        conn->ctx->dirty_pollset = 1;
+        serf_io__set_pollset_dirty(&conn->io);
         conn->stop_writing = 0;
         conn->write_now = 1;
 

Modified: serf/trunk/outgoing_request.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/outgoing_request.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/outgoing_request.c (original)
+++ serf/trunk/outgoing_request.c Wed Nov 18 12:58:21 2015
@@ -219,14 +219,14 @@ apr_status_t serf__handle_response(serf_
             /* There was an error while checking the authentication headers of
                the response. We need to inform the application - which
                hasn't seen this response yet - of the error.
-             
+
                These are the possible causes of the error:
 
                1. A communication error while reading the response status line,
                   headers or while discarding the response body: pass the
                   response unchanged to the application, it will see the same
                   error as serf did.
-             
+
                2. A 401/407 response status for a supported authn scheme that
                   resulted in authn failure:
                   Pass the response as received to the application, the 
response
@@ -243,7 +243,7 @@ apr_status_t serf__handle_response(serf_
                   Pass the response headers to the application. The response
                   body is untrusted, so we should drop it and return the AUTHN
                   error instead of APR_EOF.
-             
+
                   serf__handle_auth_response will already discard the response
                   body, so we can handle this case the same as 2.
 
@@ -372,8 +372,7 @@ serf_request_t *serf_connection_request_
     conn->nr_of_unwritten_reqs++;
 
     /* Ensure our pollset becomes writable in context run */
-    conn->ctx->dirty_pollset = 1;
-    conn->dirty_conn = 1;
+    serf_io__set_pollset_dirty(&conn->io);
 
     return request;
 }
@@ -405,7 +404,7 @@ priority_request_create(serf_connection_
 
     /* A CONNECT request to setup an ssltunnel has absolute priority over all
        other requests on the connection, so:
-       a. add it first to the queue 
+       a. add it first to the queue
        b. ensure that other priority requests are added after the CONNECT
           request */
     if (!request->ssltunnel) {
@@ -426,8 +425,7 @@ priority_request_create(serf_connection_
     conn->nr_of_unwritten_reqs++;
 
     /* Ensure our pollset becomes writable in context run */
-    conn->ctx->dirty_pollset = 1;
-    conn->dirty_conn = 1;
+    serf_io__set_pollset_dirty(&conn->io);
 
     return request;
 }

Modified: serf/trunk/protocols/fcgi_protocol.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/protocols/fcgi_protocol.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/protocols/fcgi_protocol.c (original)
+++ serf/trunk/protocols/fcgi_protocol.c Wed Nov 18 12:58:21 2015
@@ -36,13 +36,13 @@
 
 typedef struct serf_fcgi_protocol_t
 {
-    serf_context_t *ctx;
     serf_connection_t *conn;
     serf_incoming_t *client;
 
+    serf_io_baton_t *io; /* Low level connection */
+
     apr_pool_t *pool;
     serf_bucket_alloc_t *allocator;
-    bool *dirty_pollset;
     serf_config_t *config;
 
     apr_int16_t *req_events;
@@ -354,7 +354,7 @@ apr_status_t serf_fcgi__enqueue_frame(se
     apr_status_t status;
     bool want_write;
 
-    if (!pump && !*fcgi->dirty_pollset)
+    if (!pump && !fcgi->io->dirty_conn)
     {
         const char *data;
         apr_size_t len;
@@ -371,8 +371,7 @@ apr_status_t serf_fcgi__enqueue_frame(se
 
         if (len == 0)
         {
-            *fcgi->dirty_pollset = true;
-            fcgi->ctx->dirty_pollset = true;
+            serf_io__set_pollset_dirty(fcgi->io);
         }
     }
 
@@ -392,8 +391,7 @@ apr_status_t serf_fcgi__enqueue_frame(se
     if ((want_write && !(*fcgi->req_events & APR_POLLOUT))
         || (!want_write && (*fcgi->req_events & APR_POLLOUT)))
     {
-        *fcgi->dirty_pollset = true;
-        fcgi->ctx->dirty_pollset = true;
+        serf_io__set_pollset_dirty(fcgi->io);
     }
 
     return status;
@@ -414,8 +412,7 @@ static apr_status_t fcgi_write(serf_fcgi
         return status;
 
     /* Probably nothing to write. */
-    *fcgi->dirty_pollset = true;
-    fcgi->ctx->dirty_pollset = true;
+    serf_io__set_pollset_dirty(fcgi->io);
 
     return APR_SUCCESS;
 }
@@ -541,8 +538,7 @@ void serf__fcgi_protocol_init(serf_conne
     fcgi = apr_pcalloc(protocol_pool, sizeof(*fcgi));
     fcgi->pool = protocol_pool;
     fcgi->conn = conn;
-    fcgi->ctx = conn->ctx;
-    fcgi->dirty_pollset = &conn->dirty_conn;
+    fcgi->io = &conn->io;
     fcgi->req_events = &conn->reqevents;
     fcgi->stream = conn->stream;
     fcgi->ostream = conn->ostream_tail;
@@ -612,8 +608,7 @@ void serf__fcgi_protocol_init_server(ser
     fcgi = apr_pcalloc(protocol_pool, sizeof(*fcgi));
     fcgi->pool = protocol_pool;
     fcgi->client = client;
-    fcgi->ctx = client->ctx;
-    fcgi->dirty_pollset = &client->dirty_conn;
+    fcgi->io = &client->io;
     fcgi->req_events = &client->reqevents;
     fcgi->stream = client->stream;
     fcgi->ostream = client->ostream_tail;

Modified: serf/trunk/protocols/http2_protocol.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/protocols/http2_protocol.c?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/protocols/http2_protocol.c (original)
+++ serf/trunk/protocols/http2_protocol.c Wed Nov 18 12:58:21 2015
@@ -120,8 +120,9 @@ struct serf_http2_protocol_t
     apr_pool_t *pool;
     serf_connection_t *conn; /* Either CONN or CLIENT is set */
     serf_incoming_t *client;
-    serf_context_t *ctx;
-    bool *dirty_pollset;
+
+    serf_io_baton_t *io; /* Low level connection */
+
     apr_int16_t *req_events;
     serf_bucket_t *stream, *ostream;
     serf_bucket_alloc_t *allocator;
@@ -238,8 +239,7 @@ void serf__http2_protocol_init(serf_conn
     h2 = apr_pcalloc(protocol_pool, sizeof(*h2));
     h2->pool = protocol_pool;
     h2->conn = conn;
-    h2->ctx = conn->ctx;
-    h2->dirty_pollset = &conn->dirty_conn;
+    h2->io = &conn->io;
     h2->req_events = &conn->reqevents;
     h2->stream = conn->stream;
     h2->ostream = conn->ostream_tail;
@@ -332,8 +332,7 @@ void serf__http2_protocol_init_server(se
     h2 = apr_pcalloc(protocol_pool, sizeof(*h2));
     h2->pool = protocol_pool;
     h2->client = client;
-    h2->ctx = client->ctx;
-    h2->dirty_pollset = &client->dirty_conn;
+    h2->io = &client->io;
     h2->req_events = &client->reqevents;
     h2->stream = client->stream;
     h2->ostream = client->ostream_tail;
@@ -442,7 +441,7 @@ serf_http2__enqueue_frame(serf_http2_pro
     bool want_write;
 
 
-    if (!pump && !*h2->dirty_pollset)
+    if (!pump && !h2->io->dirty_conn)
     {
         const char *data;
         apr_size_t len;
@@ -459,8 +458,7 @@ serf_http2__enqueue_frame(serf_http2_pro
 
         if (len == 0)
         {
-            *h2->dirty_pollset = true;
-            h2->ctx->dirty_pollset = true;
+            serf_io__set_pollset_dirty(h2->io);
         }
     }
 
@@ -480,8 +478,7 @@ serf_http2__enqueue_frame(serf_http2_pro
     if ((want_write && !(*h2->req_events & APR_POLLOUT))
         || (!want_write && (*h2->req_events & APR_POLLOUT)))
     {
-        *h2->dirty_pollset = true;
-        h2->ctx->dirty_pollset = true;
+        serf_io__set_pollset_dirty(h2->io);
     }
 
     return status;
@@ -1653,8 +1650,7 @@ http2_outgoing_read(serf_connection_t *c
     if (conn->stop_writing)
     {
         conn->stop_writing = 0;
-        conn->dirty_conn = 1;
-        conn->ctx->dirty_pollset = 1;
+        serf_io__set_pollset_dirty(&conn->io);
     }
 
     if (h2->stream == NULL)
@@ -1705,8 +1701,7 @@ http2_outgoing_write(serf_connection_t *
         return status;
 
       /* Probably nothing to write. Connection will check new requests */
-    conn->dirty_conn = 1;
-    h2->ctx->dirty_pollset = 1;
+    serf_io__set_pollset_dirty(&conn->io);
 
     return APR_SUCCESS;
 }
@@ -1739,8 +1734,7 @@ http2_incoming_read(serf_incoming_t *cli
     if (client->stop_writing)
     {
         client->stop_writing = 0;
-        client->dirty_conn = 1;
-        client->ctx->dirty_pollset = 1;
+        serf_io__set_pollset_dirty(&client->io);
     }
 
     if (h2->prefix_left) {
@@ -1824,8 +1818,7 @@ http2_incoming_write(serf_incoming_t *cl
         return status;
 
     /* Probably nothing to write. Connection will check new requests */
-    client->dirty_conn = true;
-    h2->ctx->dirty_pollset = true;
+    serf_io__set_pollset_dirty(&client->io);
 
     return APR_SUCCESS;
 }

Modified: serf/trunk/serf_private.h
URL: 
http://svn.apache.org/viewvc/serf/trunk/serf_private.h?rev=1714990&r1=1714989&r2=1714990&view=diff
==============================================================================
--- serf/trunk/serf_private.h (original)
+++ serf/trunk/serf_private.h Wed Nov 18 12:58:21 2015
@@ -137,8 +137,21 @@ typedef struct serf_io_baton_t {
         serf_connection_t *conn;
         serf_listener_t *listener;
     } u;
+
+    /* are we a dirty connection that needs its poll status updated? */
+    serf_context_t *ctx;
+    bool dirty_conn;
+
 } serf_io_baton_t;
 
+/* Should we use static APR_INLINE instead? */
+#define serf_io__set_pollset_dirty(io_baton)                    \
+    do                                                          \
+    {   serf_io_baton_t *serf__tmp_io_baton = io_baton;         \
+        serf__tmp_io_baton->dirty_conn = true;                  \
+        serf__tmp_io_baton->ctx->dirty_pollset = true;          \
+    } while (0)
+
 typedef enum serf_request_writing_t {
     SERF_WRITING_NONE,          /* Nothing written */
     SERF_WRITING_STARTED,       /* Data in write bucket(s) */
@@ -353,7 +366,7 @@ struct serf_context_t {
 
 struct serf_listener_t {
     serf_context_t *ctx;
-    serf_io_baton_t baton;
+    serf_io_baton_t io;
     apr_socket_t *skt;
     apr_pool_t *pool;
     apr_pollfd_t desc;
@@ -364,7 +377,7 @@ struct serf_listener_t {
 struct serf_incoming_t {
     serf_context_t *ctx;
 
-    serf_io_baton_t baton;
+    serf_io_baton_t io;
     serf_incoming_request_setup_t req_setup;
     void *req_setup_baton;
 
@@ -388,7 +401,6 @@ struct serf_incoming_t {
 
     serf_connection_framing_type_t framing_type;
 
-    bool dirty_conn;
     bool wait_for_connect;
     bool hit_eof;
     bool stop_writing;
@@ -431,7 +443,7 @@ struct serf_connection_t {
     serf_context_t *ctx;
 
     apr_status_t status;
-    serf_io_baton_t baton;
+    serf_io_baton_t io;
 
     apr_pool_t *pool;
     serf_bucket_alloc_t *allocator;
@@ -447,9 +459,6 @@ struct serf_connection_t {
     /* the events we've seen for this connection in our returned pollset */
     apr_int16_t seen_in_pollset;
 
-    /* are we a dirty connection that needs its poll status updated? */
-    bool dirty_conn;
-
     /* number of completed requests we've sent */
     unsigned int completed_requests;
 


Reply via email to