serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1709631 - /serf/trunk/outgoing.c
Date Tue, 20 Oct 2015 16:09:23 GMT
Author: rhuijben
Date: Tue Oct 20 16:09:23 2015
New Revision: 1709631

URL: http://svn.apache.org/viewvc?rev=1709631&view=rev
Log:
Simplify a bit of logic in the http1.1 output pipeline by removing some
duplicated code and properly handling the relation between errors and
hitting EOF.

Hitting eof implies getting an error or status APR_EAGAIN, as that is
what our callback does.

* outgoing.c
  (write_to_connection): Simplify.

Modified:
    serf/trunk/outgoing.c

Modified: serf/trunk/outgoing.c
URL: http://svn.apache.org/viewvc/serf/trunk/outgoing.c?rev=1709631&r1=1709630&r2=1709631&view=diff
==============================================================================
--- serf/trunk/outgoing.c (original)
+++ serf/trunk/outgoing.c Tue Oct 20 16:09:23 2015
@@ -812,30 +812,33 @@ static apr_status_t write_to_connection(
                                              conn->vec,
                                              &conn->vec_len);
 
-        if (!conn->hit_eof) {
-            if (APR_STATUS_IS_EAGAIN(read_status)) {
-                /* We read some stuff, but should not try to read again. */
+        if (read_status == SERF_ERROR_WAIT_CONN) {
+
+            /* The bucket told us that it can't provide more data until
+               more data is read from the socket. This normally happens
+               during a SSL handshake.
+
+               We should avoid looking for writability for a while so
+               that (hopefully) something will appear in the bucket so
+               we can actually write something. otherwise, we could
+               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;
+        }
+        else if (APR_STATUS_IS_EAGAIN(read_status)) {
+
+            /* We read some stuff, but should not try to read again. */
+
+            if (! conn->hit_eof)
                 stop_reading = 1;
-            }
-            else if (read_status == SERF_ERROR_WAIT_CONN) {
-                /* The bucket told us that it can't provide more data until
-                   more data is read from the socket. This normally happens
-                   during a SSL handshake.
-
-                   We should avoid looking for writability for a while so
-                   that (hopefully) something will appear in the bucket so
-                   we can actually write something. otherwise, we could
-                   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;
-            }
-            else if (read_status && !APR_STATUS_IS_EOF(read_status)) {
-                /* Something bad happened. Propagate any errors. */
-                return read_status;
-            }
+        }
+        else if (SERF_BUCKET_READ_ERROR(read_status)) {
+
+            /* Something bad happened. Propagate any errors. */
+
+            return read_status;
         }
 
         /* If we got some data, then deliver it. */
@@ -848,9 +851,6 @@ static apr_status_t write_to_connection(
 
         if (read_status == SERF_ERROR_WAIT_CONN) {
             stop_reading = 1;
-            conn->stop_writing = 1;
-            conn->dirty_conn = 1;
-            conn->ctx->dirty_pollset = 1;
         }
         else if (request && read_status && conn->hit_eof &&
                  conn->vec_len == 0) {



Mime
View raw message