httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ic...@apache.org
Subject svn commit: r1722857 - in /httpd/test/mod_h2/trunk: Makefile.am conf/httpd.conf mh2fuzz/h2c_conn.c mh2fuzz/h2c_conn.h mh2fuzz/h2c_request.c mh2fuzz/h2c_session.c mh2fuzz/h2c_worker.c mh2fuzz/mh2f_fuzzer.c
Date Mon, 04 Jan 2016 12:32:09 GMT
Author: icing
Date: Mon Jan  4 12:32:08 2016
New Revision: 1722857

URL: http://svn.apache.org/viewvc?rev=1722857&view=rev
Log:
random-delay fuzzer fixes for getting stuck, no delay on first write

Modified:
    httpd/test/mod_h2/trunk/Makefile.am
    httpd/test/mod_h2/trunk/conf/httpd.conf
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_request.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c
    httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c

Modified: httpd/test/mod_h2/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/Makefile.am?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/Makefile.am (original)
+++ httpd/test/mod_h2/trunk/Makefile.am Mon Jan  4 12:32:08 2016
@@ -173,6 +173,8 @@ h2cload: \
 fuzz: $(MH2FUZZ)
 	@for i in 0 1 2 3 4 5 6 7 8 9; do echo "fuzz $$i..."; $(MH2FUZZ) -q -t 4 -c 75 -m 10 -n
100000 -f random-close10 http://$(HTTP_AUTH)/ ; done
 
+fuzz-delay: $(MH2FUZZ)
+	@for i in 0 1 2 3 4 5 6 7 8 9; do echo "fuzz-delay $$i..."; $(MH2FUZZ) -q -t 4 -c 75 -m
10 -n 100000 -f random-delay10 http://$(HTTP_AUTH)/ ; done
 
 ################################################################################
 # Switch mpm modules

Modified: httpd/test/mod_h2/trunk/conf/httpd.conf
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/conf/httpd.conf?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/conf/httpd.conf (original)
+++ httpd/test/mod_h2/trunk/conf/httpd.conf Mon Jan  4 12:32:08 2016
@@ -61,7 +61,8 @@ DocumentRoot "SUBST_SERVER_ROOT_SUBST/ht
 
 # unlimited connection reuse
 MaxKeepAliveRequests 0
-MaxConnectionsPerChild 1000
+Timeout 5
+KeepAliveTimeout 60
 
     #LogLevel core:debug
     #LogLevel ssl:debug
@@ -71,7 +72,7 @@ MaxConnectionsPerChild 1000
     #LogLevel dumpio:trace7
 
 <IfModule http2_module>
-    LogLevel http2:info
+    LogLevel http2:trace1
     
     # max parallel streams per session, default 100
     #H2MaxSessionStreams

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c Mon Jan  4 12:32:08 2016
@@ -54,6 +54,7 @@ static apr_status_t read_plain(h2c_conn
     }
     status = apr_socket_recv(c->socket, buffer, &len);
     if (len > 0) {
+        c->read_bytes += len;
         apr_status_t s2 = on_read(c, buffer, len);
         if (status == APR_SUCCESS) {
             status = s2;
@@ -75,6 +76,7 @@ static apr_status_t write_plain(h2c_conn
         if (len > 0) {
             c->buf_head += len;
             c->buf_len -= len;
+            c->written_bytes += len;
         }
     }
     return status;
@@ -145,7 +147,7 @@ void h2c_conn_destroy(h2c_conn *c)
 
 void h2c_conn_want_io(h2c_conn *c, int flags)
 {
-    int pf = 0;
+    int pf = (APR_POLLHUP|APR_POLLERR);
     if (flags & H2C_CONN_READ) {
         pf |= APR_POLLIN;
     }

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h Mon Jan  4 12:32:08 2016
@@ -57,6 +57,9 @@ struct h2c_conn {
     apr_size_t             buf_head;
     apr_size_t             buf_len;
     
+    apr_off_t              written_bytes;
+    apr_off_t              read_bytes;
+    
     h2c_conn_obs           *obs;
     int                    verbose;
 };

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_request.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_request.c?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_request.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_request.c Mon Jan  4 12:32:08 2016
@@ -35,6 +35,9 @@ apr_status_t h2c_request_create(h2c_requ
        r->authority = uri->hostname;
     }
     r->path      = apr_uri_unparse(p, uri, APR_URI_UNP_OMITSITEPART);
+    if (!strcmp(r->path, "")) {
+        r->path = "/";
+    }
     r->headers   = apr_table_make(p, 5);
     
     *pr = r;

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c Mon Jan  4 12:32:08 2016
@@ -175,6 +175,10 @@ static int on_frame_recv(nghttp2_session
     switch (frame->hd.type) {
         case NGHTTP2_GOAWAY:
             s->goaway_recvd = 1;
+            if (s->c->verbose == 0) {
+                fprintf(stderr, "%ld: recv GOAWAY, err=%d\n", s->c->id,
+                        frame->goaway.error_code);
+            }
             h2c_session_close(s);
             break;
         default:
@@ -212,6 +216,40 @@ static int on_data_chunk_recv(nghttp2_se
     return 0;
 }
 
+static apr_status_t check_io_sense(h2c_session *s, apr_status_t status)
+{
+    int io_sense = 0;
+
+    if (status == APR_SUCCESS && s->feed && s->max_streams > s->open_streams)
{
+        apr_status_t s2;
+        h2c_request *r;
+        
+        s2 = h2c_feed_next(&r, s->feed, s);
+        if (s2 == APR_SUCCESS) {
+            status = h2c_session_submit(s, r, NULL);
+            io_sense |= H2C_CONN_WRITE;
+        }
+        else if (APR_STATUS_IS_EOF(s2) && s->open_streams == 0) {
+            io_sense |= H2C_CONN_READ;
+            h2c_session_close(s);
+            status = APR_EOF;
+        }
+    }
+
+    if (nghttp2_session_want_read(s->ngh2)) {
+        io_sense |= H2C_CONN_READ;
+    }
+    if (nghttp2_session_want_write(s->ngh2) || !h2c_conn_wbuf_empty(s->c)) {
+        io_sense |= H2C_CONN_WRITE;
+    }
+    if (!io_sense) {
+        return APR_EOF;
+    }
+    
+    h2c_conn_want_io(s->c, io_sense);
+    return status;
+}
+
 static int on_stream_close(nghttp2_session *ngh2, int32_t stream_id,
                            uint32_t error_code, void *user_data) 
 {
@@ -231,7 +269,7 @@ static int on_stream_close(nghttp2_sessi
     }
     
     h2c_stream_close(stream);
-    
+
     return 0;
 }
 
@@ -253,39 +291,6 @@ static int on_header(nghttp2_session *ng
     return 0;
 }
 
-static apr_status_t check_io_sense(h2c_session *s, apr_status_t status)
-{
-    int io_sense = 0;
-
-    if (status == APR_SUCCESS && s->feed && s->max_streams > s->open_streams)
{
-        apr_status_t s2;
-        h2c_request *r;
-        
-        s2 = h2c_feed_next(&r, s->feed, s);
-        if (s2 == APR_SUCCESS) {
-            status = h2c_session_submit(s, r, NULL);
-        }
-        else if (APR_STATUS_IS_EOF(s2) && s->open_streams == 0) {
-            io_sense |= H2C_CONN_READ;
-            h2c_session_close(s);
-            status = APR_EOF;
-        }
-    }
-
-    if (nghttp2_session_want_read(s->ngh2)) {
-        io_sense |= H2C_CONN_READ;
-    }
-    if (nghttp2_session_want_write(s->ngh2) || !h2c_conn_wbuf_empty(s->c)) {
-        io_sense |= H2C_CONN_WRITE;
-    }
-    if (!io_sense) {
-        return APR_EOF;
-    }
-    
-    h2c_conn_want_io(s->c, io_sense);
-    return status;
-}
-
 static apr_status_t on_conn_read(h2c_conn *c, const char *data, size_t len, void *ctx)
 {
     h2c_session *s = ctx;
@@ -393,6 +398,6 @@ apr_status_t h2c_session_submit(h2c_sess
     if (pid) {
         *pid =  stream_id;
     }
-    return check_io_sense(s, APR_SUCCESS);
+    return APR_SUCCESS;
 }
 

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c Mon Jan  4 12:32:08 2016
@@ -120,7 +120,7 @@ apr_status_t h2c_worker_run(h2c_worker *
         const apr_pollfd_t *pdesc;
         const char *op;
 
-        status = apr_pollset_poll(pollset, apr_time_from_sec(10),
+        status = apr_pollset_poll(pollset, apr_time_from_sec(60),
                                   &numdesc, &pdesc);
                                   
         if (status != APR_SUCCESS) {
@@ -142,6 +142,9 @@ apr_status_t h2c_worker_run(h2c_worker *
             if (pfd->rtnevents & APR_POLLIN) {
                 op = "reading";
                 status = h2c_conn_read(c);
+                if (status == APR_SUCCESS) {
+                    status = h2c_conn_write(c);
+                }
             }
             if (pfd->rtnevents & APR_POLLOUT) {
                 op = "writing";

Modified: httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c?rev=1722857&r1=1722856&r2=1722857&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c Mon Jan  4 12:32:08 2016
@@ -155,7 +155,7 @@ static apr_status_t rd_delay(h2c_conn *c
 {
     int delay_ms = (f->max_delay * (rand() % 1001)); 
     if (status == APR_SUCCESS && delay_ms > 0) {
-        if (c->verbose > 0) {
+        if (c->verbose >= 0) {
             fprintf(stderr, "random-delay(%d): delaying conn %ld by %d ms\n", 
                     f->max_delay, c->id, delay_ms);
         }
@@ -167,22 +167,23 @@ static apr_status_t rd_delay(h2c_conn *c
 static apr_status_t rd_on_connect(h2c_conn *c, void *ctx)
 {
     fuzzer_rd *f = ctx;
-    return rd_delay(c, f, (f->prev && f->prev->on_connect)? 
-                    f->prev->on_connect(c, f->prev->ctx) : APR_SUCCESS);
+    return ((f->prev && f->prev->on_connect)? 
+            f->prev->on_connect(c, f->prev->ctx) : APR_SUCCESS);
 }
 
 static apr_status_t rd_on_read(h2c_conn *c, const char *data, apr_size_t len, void *ctx)
 {
     fuzzer_rd *f = ctx;
-    return rd_delay(c, f, (f->prev && f->prev->on_read)? 
-                    f->prev->on_read(c, data, len, f->prev->ctx) : APR_SUCCESS);
+    return ((f->prev && f->prev->on_read)? 
+            f->prev->on_read(c, data, len, f->prev->ctx) : APR_SUCCESS);
 }
 
 static apr_status_t rd_on_write(h2c_conn *c, void *ctx)
 {
     fuzzer_rd *f = ctx;
-    return rd_delay(c, f, (f->prev && f->prev->on_write)? 
+    apr_status_t status = ((f->prev && f->prev->on_write)? 
                     f->prev->on_write(c, f->prev->ctx) : APR_SUCCESS);
+    return c->written_bytes? rd_delay(c, f, status) : status;
 }
 
 static apr_status_t rd_before_close(h2c_conn *c, void *ctx)
@@ -231,7 +232,7 @@ struct h2c_conn_obs *mh2f_conn_fuzzer_cr
         return rc_create(name, p, prev);
     }
     else if (HAS_PREFIX("random-delay", name)) {
-        return rc_create(name, p, prev);
+        return rd_create(name, p, prev);
     }
     return NULL;
 }



Mime
View raw message