httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ic...@apache.org
Subject svn commit: r1728097 - in /httpd/test/mod_h2/trunk: conf/ conf/sites/ mh2fuzz/
Date Tue, 02 Feb 2016 12:18:48 GMT
Author: icing
Date: Tue Feb  2 12:18:48 2016
New Revision: 1728097

URL: http://svn.apache.org/viewvc?rev=1728097&view=rev
Log:
some rework of fuzzers, new stop-read fuzzer

Modified:
    httpd/test/mod_h2/trunk/conf/httpd.conf
    httpd/test/mod_h2/trunk/conf/sites/test-ser.example.org.conf
    httpd/test/mod_h2/trunk/conf/sites/test.example.org.conf
    httpd/test/mod_h2/trunk/conf/sites/test2.example.org.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_session.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.h
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c
    httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c
    httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.h
    httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c

Modified: httpd/test/mod_h2/trunk/conf/httpd.conf
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/conf/httpd.conf?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/conf/httpd.conf (original)
+++ httpd/test/mod_h2/trunk/conf/httpd.conf Tue Feb  2 12:18:48 2016
@@ -75,8 +75,6 @@ DocumentRoot "SUBST_SERVER_ROOT_SUBST/ht
 
 # unlimited connection reuse
 MaxKeepAliveRequests 0
-#Timeout 1
-#KeepAliveTimeout 5
 
     #LogLevel core:debug
     #LogLevel ssl:debug    
@@ -85,7 +83,7 @@ MaxKeepAliveRequests 0
     #LogLevel dumpio:trace7
 
 <IfModule http2_module>
-    LogLevel http2:info
+    LogLevel http2:debug
     
     # max parallel streams per session, default 100
     #H2MaxSessionStreams
@@ -129,20 +127,20 @@ MaxKeepAliveRequests 0
 # SSL Setup
 ################################################################################
 <IfModule ssl_module>
-	SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
-	SSLProtocol All -SSLv2 -SSLv3
-	SSLPassPhraseDialog  builtin
-	SSLSessionCache        "shmcb:logs/ssl_scache(512000)"
-	SSLSessionCacheTimeout  300
-
-	SSLRandomSeed startup builtin
-	SSLRandomSeed connect builtin
-
-	Listen SUBST_PORT_HTTPS_SUBST
+    SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
+    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
   
+    SSLHonorCipherOrder on
+    SSLPassPhraseDialog  builtin
+    SSLSessionCache        "shmcb:logs/ssl_scache(512000)"
+    SSLSessionCacheTimeout  300
+    
+    SSLRandomSeed startup builtin
+    SSLRandomSeed connect builtin
 
-	SSLUseStapling On
-	SSLStaplingCache shmcb:logs/ssl_stapling(32768)
+    Listen SUBST_PORT_HTTPS_SUBST
 
+    SSLUseStapling On
+    SSLStaplingCache shmcb:logs/ssl_stapling(32768)
 </IfModule>
 
 ################################################################################

Modified: httpd/test/mod_h2/trunk/conf/sites/test-ser.example.org.conf
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/conf/sites/test-ser.example.org.conf?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/conf/sites/test-ser.example.org.conf (original)
+++ httpd/test/mod_h2/trunk/conf/sites/test-ser.example.org.conf Tue Feb  2 12:18:48 2016
@@ -16,9 +16,6 @@
     KeepAliveTimeout 60
     
     SSLEngine on
-    SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
-    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
-    SSLHonorCipherOrder on
     SSLCertificateFile conf/ssl/test.example.org.pem
     SSLCertificateKeyFile conf/ssl/test.example.org.key
 

Modified: httpd/test/mod_h2/trunk/conf/sites/test.example.org.conf
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/conf/sites/test.example.org.conf?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/conf/sites/test.example.org.conf (original)
+++ httpd/test/mod_h2/trunk/conf/sites/test.example.org.conf Tue Feb  2 12:18:48 2016
@@ -25,21 +25,18 @@
     DocumentRoot "SUBST_SERVER_ROOT_SUBST/htdocs/test.example.org"
     Protocols h2 http/1.1
 
+    Timeout 2
+    KeepAliveTimeout 10
+    
     SSLEngine on
-    SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
-    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
   
-    SSLHonorCipherOrder on
     SSLCertificateFile conf/ssl/test.example.org.pem
     SSLCertificateKeyFile conf/ssl/test.example.org.key
 
     RewriteEngine on
     RewriteRule ^/latest.tar.gz$ /xxx-1.0.2a.tar.gz [R=302,NC]
-    ProxyTimeout 5
+    ProxyTimeout 10
 
     <IfModule http2_module>
-        Timeout 2
-        KeepAliveTimeout 10
-
         H2Direct on
         H2AltSvc h2=test.example.org:12346
         H2AltSvc h2c=:12345

Modified: httpd/test/mod_h2/trunk/conf/sites/test2.example.org.conf
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/conf/sites/test2.example.org.conf?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/conf/sites/test2.example.org.conf (original)
+++ httpd/test/mod_h2/trunk/conf/sites/test2.example.org.conf Tue Feb  2 12:18:48 2016
@@ -11,9 +11,6 @@
     Protocols http/1.1 h2
 
     SSLEngine on
-    SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
-    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
      
-    SSLHonorCipherOrder on
     SSLCertificateFile conf/ssl/test.example.org.pem
     SSLCertificateKeyFile conf/ssl/test.example.org.key
 

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=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c Tue Feb  2 12:18:48 2016
@@ -31,20 +31,92 @@ static long cid;
 
 static apr_size_t BUF_SIZE = 16 * 1024;
 
+static apr_status_t on_connect(h2c_conn *c)
+{
+    apr_status_t status = APR_SUCCESS;
+    h2c_conn_obs *obs = c->obs;
+    while (obs && status == APR_SUCCESS) {
+        if (obs->on_connect) {
+            status = obs->on_connect(c, obs);
+        }
+        obs = obs->next;
+    }
+    return status;
+}
+
+static apr_status_t on_before_read(h2c_conn *c)
+{
+    apr_status_t status = APR_SUCCESS;
+    if (c->connected) {
+        h2c_conn_obs *obs = c->obs;
+        while (obs && status == APR_SUCCESS) {
+            if (obs->before_read) {
+                status = obs->before_read(c, obs);
+            }
+            obs = obs->next;
+        }
+    }
+    return status;
+}
+
 static apr_status_t on_read(h2c_conn *c, const char *data, apr_size_t len)
 {
-    if (c->connected && c->obs && c->obs->on_read) {
-        return c->obs->on_read(c, data, len, c->obs->ctx);
+    apr_status_t status = APR_SUCCESS;
+    if (c->connected) {
+        h2c_conn_obs *obs = c->obs;
+        while (obs && status == APR_SUCCESS) {
+            if (obs->on_read) {
+                status = obs->on_read(c, data, len, obs);
+            }
+            obs = obs->next;
+        }
     }
-    return APR_SUCCESS;
+    return status;
 }
 
 static apr_status_t on_write(h2c_conn *c)
 {
-    if (c->connected && c->obs && c->obs->on_write) {
-        return c->obs->on_write(c, c->obs->ctx);
+    apr_status_t status = APR_SUCCESS;
+    if (c->connected) {
+        h2c_conn_obs *obs = c->obs;
+        while (obs && status == APR_SUCCESS) {
+            if (obs->on_write) {
+                status = obs->on_write(c, obs);
+            }
+            obs = obs->next;
+        }
     }
-    return APR_SUCCESS;
+    return status;
+}
+
+static apr_status_t on_before_shutdown(h2c_conn *c)
+{
+    apr_status_t status = APR_SUCCESS;
+    if (c->connected) {
+        h2c_conn_obs *obs = c->obs;
+        while (obs && status == APR_SUCCESS) {
+            if (obs->before_shutdown) {
+                status = obs->before_shutdown(c, obs);
+            }
+            obs = obs->next;
+        }
+    }
+    return status;
+}
+
+static apr_status_t on_before_close(h2c_conn *c)
+{
+    apr_status_t status = APR_SUCCESS;
+    if (c->connected) {
+        h2c_conn_obs *obs = c->obs;
+        while (obs && status == APR_SUCCESS) {
+            if (obs->before_close) {
+                status = obs->before_close(c, obs);
+            }
+            obs = obs->next;
+        }
+    }
+    return status;
 }
 
 static apr_status_t read_plain(h2c_conn *c)
@@ -57,12 +129,15 @@ static apr_status_t read_plain(h2c_conn
         if (!c->socket) {
             return APR_EOF;
         }
-        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;
+        status = on_before_read(c);
+        if (status == APR_SUCCESS) {
+            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;
+                }
             }
         }
     }
@@ -129,6 +204,10 @@ static apr_status_t tls_read(h2c_conn *c
     apr_size_t len = H2_DIM(buffer);
 
     while (status == APR_SUCCESS) {
+        status = on_before_read(c);
+        if (status != APR_SUCCESS) {
+            return status;
+        }
         ERR_clear_error();
         if (!c->socket) {
             return APR_EOF;
@@ -209,10 +288,7 @@ static apr_status_t connected(h2c_conn *
     }
     
     c->connected = 1;
-    if (c->obs && c->obs->on_connect) {
-        return c->obs->on_connect(c, c->obs->ctx);
-    }
-    return APR_SUCCESS;
+    return on_connect(c);
 }
 
 static apr_status_t tls_handshake(h2c_conn *c) {
@@ -340,13 +416,28 @@ h2c_conn_obs *h2c_conn_obs_get(h2c_conn
     return c->obs;
 }
 
-void h2c_conn_obs_set(h2c_conn *c, h2c_conn_obs *obs)
+static h2c_conn_obs *obs_setup(h2c_conn *c, h2c_conn_obs *obs)
 {
-    if (obs->setup) {
-        c->obs = obs->setup(c, obs->ctx);
+    if (obs) {
+        h2c_conn_obs *nobs = obs->next;
+        if (obs->setup) {
+            obs = obs->setup(c, obs);
+        }
+        obs->next = obs_setup(c, nobs);
     }
-    else {
-        c->obs = obs;
+    return obs;
+}
+
+void h2c_conn_obs_set(h2c_conn *c, h2c_conn_obs *obs)
+{    
+    h2c_conn_obs *tail = c->obs? c->obs : NULL;
+    c->obs = obs_setup(c, obs);
+    if (tail) {
+        h2c_conn_obs **pnext = &c->obs;
+        while (*pnext) {
+            pnext = &((*pnext)->next);
+        }
+        *pnext = tail;
     }
 }
 
@@ -416,9 +507,7 @@ apr_status_t h2c_conn_shutdown(h2c_conn
         if (c->verbose > 1) {
             fprintf(stderr, "h2c_conn(%ld): shutting down\n", c->id);
         }
-        if (c->connected && c->obs && c->obs->before_shutdown)
{
-            c->obs->before_shutdown(c, c->obs->ctx);
-        }
+        on_before_shutdown(c);
         
         status = c->write(c);
         if (!c->ssl) {
@@ -443,9 +532,7 @@ apr_status_t h2c_conn_close(h2c_conn *c)
         if (c->verbose > 1) {
             fprintf(stderr, "h2c_conn(%ld): closing\n", c->id);
         }
-        if (c->connected && c->obs && c->obs->before_close) {
-            c->obs->before_close(c, c->obs->ctx);
-        }
+        on_before_close(c);
         
         if (status == APR_SUCCESS) {
             status = apr_socket_close(c->socket);

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=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h Tue Feb  2 12:18:48 2016
@@ -20,9 +20,9 @@ struct apr_pollfd_t;
 typedef struct h2c_conn h2c_conn;
 typedef struct h2c_conn_obs h2c_conn_obs;
 
-typedef h2c_conn_obs *h2c_conn_obs_setup(h2c_conn *c, void *ctx);
-typedef apr_status_t h2c_conn_obs_cb(h2c_conn *c, void *ctx);
-typedef apr_status_t h2c_conn_on_read_cb(h2c_conn *c, const char *data, apr_size_t len, void
*ctx);
+typedef h2c_conn_obs *h2c_conn_obs_setup(h2c_conn *c, h2c_conn_obs *obs);
+typedef apr_status_t h2c_conn_obs_cb(h2c_conn *c, h2c_conn_obs *obs);
+typedef apr_status_t h2c_conn_on_read_cb(h2c_conn *c, const char *data, apr_size_t len, h2c_conn_obs
*obs);
 
 typedef apr_status_t h2c_conn_io(h2c_conn *c);
 
@@ -30,10 +30,12 @@ struct h2c_conn_obs {
     void                   *ctx;
     h2c_conn_obs_setup     *setup;
     h2c_conn_obs_cb        *on_connect;
+    h2c_conn_obs_cb        *before_read;
     h2c_conn_on_read_cb    *on_read;
     h2c_conn_obs_cb        *on_write;
     h2c_conn_obs_cb        *before_shutdown;
     h2c_conn_obs_cb        *before_close;
+    struct h2c_conn_obs    *next;
 };
 
 #define H2C_CONN_READ   0x01

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=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c Tue Feb  2 12:18:48 2016
@@ -25,10 +25,10 @@
 #include "h2c_stream.h"
 #include "h2c_util.h"
 
-static apr_status_t on_conn_connect(h2c_conn *c, void *ctx);
-static apr_status_t on_conn_read(h2c_conn *c, const char *data, size_t len, void *ctx);
-static apr_status_t on_conn_write(h2c_conn *c, void *ctx);
-static apr_status_t on_conn_shutdown(h2c_conn *c, void *ctx);
+static apr_status_t on_conn_connect(h2c_conn *c, h2c_conn_obs *obs);
+static apr_status_t on_conn_read(h2c_conn *c, const char *data, size_t len, h2c_conn_obs
*obs);
+static apr_status_t on_conn_write(h2c_conn *c, h2c_conn_obs *obs);
+static apr_status_t on_conn_shutdown(h2c_conn *c, h2c_conn_obs *obs);
 
 apr_status_t h2c_session_create(h2c_session **ps, h2c_conn *c, int max_streams,
                                 int push)
@@ -76,6 +76,7 @@ static apr_status_t h2c_session_close(h2
 
 void h2c_session_obs_set(h2c_session *s, h2c_session_obs *obs)
 {
+    obs->next = s->obs;
     s->obs = obs;
 }
 
@@ -249,6 +250,7 @@ static int on_frame_recv(nghttp2_session
     h2c_session *s = user_data;
     h2c_stream *stream;
     h2c_request *r;
+    h2c_session_obs * obs;
     
     if (s->c->verbose > 0) {
         log_frame(s, "recv", frame, stderr);
@@ -256,8 +258,12 @@ static int on_frame_recv(nghttp2_session
     switch (frame->hd.type) {
         case NGHTTP2_HEADERS:
             stream = nghttp2_session_get_stream_user_data(s->ngh2, frame->hd.stream_id);
-            if (s->obs && s->obs->on_response_headers) {
-                s->obs->on_response_headers(s, stream, NULL, s->obs->ctx);
+            obs = s->obs;
+            while (obs) {
+                if (obs->on_response_headers) {
+                    obs->on_response_headers(s, stream, NULL, obs);
+                }
+                obs = obs->next;
             }
             break;
         case NGHTTP2_PUSH_PROMISE:
@@ -353,6 +359,7 @@ static int on_stream_close(nghttp2_sessi
     h2c_session *s = user_data;
     h2c_stream *stream;
     int pushed;
+    h2c_session_obs * obs;
     
     pushed = !(stream_id & 0x01);
     if (s->c->verbose > 1) {
@@ -367,8 +374,12 @@ static int on_stream_close(nghttp2_sessi
         return 0;
     }
     
-    if (s->obs && s->obs->before_stream_close) {
-        s->obs->before_stream_close(s, stream, NULL, s->obs->ctx);
+    obs = s->obs;
+    while (obs) {
+        if (obs->before_stream_close) {
+            obs->before_stream_close(s, stream, NULL, obs);
+        }
+        obs = obs->next;
     }
     
     h2c_stream_close(stream);
@@ -415,9 +426,9 @@ static int on_header(nghttp2_session *ng
     return 0;
 }
 
-static apr_status_t on_conn_read(h2c_conn *c, const char *data, size_t len, void *ctx)
+static apr_status_t on_conn_read(h2c_conn *c, const char *data, size_t len, h2c_conn_obs
*obs)
 {
-    h2c_session *s = ctx;
+    h2c_session *s = obs->ctx;
     
     if (s->ngh2) {
         ssize_t rv = nghttp2_session_mem_recv(s->ngh2, (const uint8_t*)data, len);
@@ -429,9 +440,9 @@ static apr_status_t on_conn_read(h2c_con
     return APR_SUCCESS;
 }
 
-static apr_status_t on_conn_write(h2c_conn *c, void *ctx)
+static apr_status_t on_conn_write(h2c_conn *c, h2c_conn_obs *obs)
 {
-    h2c_session *s = ctx;
+    h2c_session *s = obs->ctx;
     
     if (s->ngh2) {
         int rv = nghttp2_session_send(s->ngh2);
@@ -444,9 +455,9 @@ static apr_status_t on_conn_write(h2c_co
     return APR_SUCCESS;
 }
 
-static apr_status_t on_conn_connect(h2c_conn *c, void *ctx)
+static apr_status_t on_conn_connect(h2c_conn *c, h2c_conn_obs *obs)
 {
-    h2c_session *s = ctx;
+    h2c_session *s = obs->ctx;
     nghttp2_session_callbacks *cbs;
     nghttp2_settings_entry settings[2];
     int add_conn_window;
@@ -484,9 +495,9 @@ static apr_status_t on_conn_connect(h2c_
     return rv? APR_EGENERAL : APR_SUCCESS;
 }
 
-static apr_status_t on_conn_shutdown(h2c_conn *c, void *ctx)
+static apr_status_t on_conn_shutdown(h2c_conn *c, h2c_conn_obs *obs)
 {
-    return h2c_session_close(ctx);
+    return h2c_session_close(obs->ctx);
 }
 
 
@@ -498,6 +509,7 @@ apr_status_t h2c_session_submit(h2c_sess
     h2c_stream *stream;
     int stream_id;
     apr_status_t status;
+    h2c_session_obs *obs;
     
     if (s->closed) {
         return APR_EOF;
@@ -512,8 +524,12 @@ apr_status_t h2c_session_submit(h2c_sess
         return status;
     }
     
-    if (s->obs && s->obs->before_submit) {
-        s->obs->before_submit(s, stream, r, s->obs->ctx);
+    obs = s->obs;
+    while (obs) {
+        if (obs->before_submit) {
+            obs->before_submit(s, stream, r, obs);
+        }
+        obs = obs->next;
     }
     
     ngh = h2c_util_ngheader_make_req(s->c->pool, r->headers, r->scheme, 

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.h
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.h?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.h Tue Feb  2 12:18:48 2016
@@ -27,12 +27,13 @@ typedef struct h2c_session h2c_session;
 typedef struct h2c_session_obs h2c_session_obs;
 
 typedef void h2c_session_obs_cb(h2c_session *s, struct h2c_stream *stream, 
-                                struct h2c_request *r, void *ctx);
+                                struct h2c_request *r, h2c_session_obs *obs);
 struct h2c_session_obs {
     void                   *ctx;
     h2c_session_obs_cb     *before_submit;
     h2c_session_obs_cb     *before_stream_close;
     h2c_session_obs_cb     *on_response_headers;
+    struct h2c_session_obs *next;
 };
 
 struct h2c_session {

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=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c Tue Feb  2 12:18:48 2016
@@ -96,6 +96,10 @@ apr_status_t h2c_worker_run(h2c_worker *
             return status;
         }
 
+        if (w->conn_fuzzer) {
+            h2c_conn_obs_set(conn, w->conn_fuzzer);
+        }
+        
         status = h2c_session_create(&session, conn, w->max_streams, w->push);
         if (status != APR_SUCCESS) {
             fprintf(stderr, "error %d creating session\n", status);
@@ -105,9 +109,6 @@ apr_status_t h2c_worker_run(h2c_worker *
         h2c_session_feed_set(session, w->feed);
         h2c_session_output_set(session, w->output);
         
-        if (w->conn_fuzzer) {
-            h2c_conn_obs_set(conn, w->conn_fuzzer);
-        }
         if (w->session_fuzzer) {
             h2c_session_obs_set(session, w->session_fuzzer);
         }

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=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.c Tue Feb  2 12:18:48 2016
@@ -27,84 +27,57 @@
 #include "h2c_session.h"
 #include "mh2f_fuzzer.h"
 
+
 /*******************************************************************************
  * fuzzing by randomly closing connection
  ******************************************************************************/
  
 typedef struct fuzzer_rc {
-    const char *name;
     h2c_conn_obs obs;
-    h2c_conn_obs *prev;
+    const char *name;
     int fail_pc;
+    int active;
 } fuzzer_rc;
 
-static h2c_conn_obs *rc_setup(h2c_conn *c, void *ctx)
+static h2c_conn_obs *rc_setup(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rc *fnew, *f = ctx;
-    
-    fnew = apr_pcalloc(c->pool, sizeof(*fnew));
-    
-    memcpy(fnew, f, sizeof(*fnew));
+    fuzzer_rc *fnew = apr_pcalloc(c->pool, sizeof(*fnew));
+    memcpy(fnew, obs->ctx, sizeof(*fnew));
     fnew->obs.ctx = fnew;
     
-    if (f->prev && f->prev->setup) {
-        fnew->prev = f->prev->setup(c, f->prev->ctx);
-    }
-    else {
-        fnew->prev = h2c_conn_obs_get(c);
-    }
-    
     return &fnew->obs;
 }
 
-static apr_status_t rc_pipe(h2c_conn *c, fuzzer_rc *f, apr_status_t status)
+static apr_status_t rc_maybe(h2c_conn *c, fuzzer_rc *f)
 {
-    if (status == APR_SUCCESS && (rand() % 100 <= f->fail_pc)) {
+    if (f->active && (rand() % 100 <= f->fail_pc)) {
         if (c->verbose > 0) {
             fprintf(stderr, "random-close(%d): closing conn %ld\n", f->fail_pc, c->id);
         }
+        f->active = 0;
         h2c_conn_close(c);
         return APR_EOF;
     }
-    return status;
+    return APR_SUCCESS;
 }
 
-static apr_status_t rc_on_connect(h2c_conn *c, void *ctx)
+static apr_status_t rc_on_connect(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rc *f = ctx;
-    return rc_pipe(c, f, (f->prev && f->prev->on_connect)? 
-                   f->prev->on_connect(c, f->prev->ctx) : APR_SUCCESS);
+    return rc_maybe(c, obs->ctx);
 }
 
-static apr_status_t rc_on_read(h2c_conn *c, const char *data, apr_size_t len, void *ctx)
+static apr_status_t rc_on_read(h2c_conn *c, const char *data, apr_size_t len, 
+                               h2c_conn_obs *obs)
 {
-    fuzzer_rc *f = ctx;
-    return rc_pipe(c, f, (f->prev && f->prev->on_read)? 
-                   f->prev->on_read(c, data, len, f->prev->ctx) : APR_SUCCESS);
+    return rc_maybe(c, obs->ctx);
 }
 
-static apr_status_t rc_on_write(h2c_conn *c, void *ctx)
+static apr_status_t rc_on_write(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rc *f = ctx;
-    return rc_pipe(c, f, (f->prev && f->prev->on_write)? 
-                   f->prev->on_write(c, f->prev->ctx) : APR_SUCCESS);
+    return rc_maybe(c, obs->ctx);
 }
 
-static apr_status_t rc_before_shutdown(h2c_conn *c, void *ctx)
-{
-    fuzzer_rc *f = ctx;
-    return ((f->prev && f->prev->before_shutdown)? 
-            f->prev->before_shutdown(c, f->prev->ctx) : APR_SUCCESS);
-}
-
-static apr_status_t rc_before_close(h2c_conn *c, void *ctx)
-{
-    fuzzer_rc *f = ctx;
-    return ((f->prev && f->prev->before_close)? 
-            f->prev->before_close(c, f->prev->ctx) : APR_SUCCESS);
-}
-
-static h2c_conn_obs *rc_create(const char *name, apr_pool_t *p, h2c_conn_obs *prev)
+static h2c_conn_obs *rc_create(const char *name, apr_pool_t *p)
 {
     fuzzer_rc *f;
     size_t prelen = sizeof("random-close")-1;
@@ -113,16 +86,14 @@ static h2c_conn_obs *rc_create(const cha
     
     f->name             = apr_pstrdup(p, name);
     f->fail_pc          = 5;
+    f->active           = 1;
     
     f->obs.ctx          = f;
     f->obs.setup        = rc_setup;
     f->obs.on_connect   = rc_on_connect;
     f->obs.on_read      = rc_on_read;
     f->obs.on_write     = rc_on_write;
-    f->obs.before_shutdown = rc_before_shutdown;
-    f->obs.before_close = rc_before_close;
-    f->prev             = prev;
-    
+
     if (strlen(f->name) > prelen) {
         int n = (int)apr_atoi64(f->name+prelen);
         if (n > 0) {
@@ -137,36 +108,25 @@ static h2c_conn_obs *rc_create(const cha
  ******************************************************************************/
  
 typedef struct fuzzer_rd {
-    const char *name;
     h2c_conn_obs obs;
-    h2c_conn_obs *prev;
+    const char *name;
     int max_delay;
     int count;
 } fuzzer_rd;
 
-static h2c_conn_obs *rd_setup(h2c_conn *c, void *ctx)
+static h2c_conn_obs *rd_setup(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rd *fnew, *f = ctx;
-    
-    fnew = apr_pcalloc(c->pool, sizeof(*fnew));
-    
-    memcpy(fnew, f, sizeof(*fnew));
+    fuzzer_rd *fnew = apr_pcalloc(c->pool, sizeof(*fnew));
+    memcpy(fnew, obs->ctx, sizeof(*fnew));
     fnew->obs.ctx = fnew;
-    
-    if (f->prev && f->prev->setup) {
-        fnew->prev = f->prev->setup(c, f->prev->ctx);
-    }
-    else {
-        fnew->prev = h2c_conn_obs_get(c);
-    }
-    
+
     return &fnew->obs;
 }
 
-static apr_status_t rd_delay(h2c_conn *c, fuzzer_rd *f, apr_status_t status)
+static void rd_delay(h2c_conn *c, fuzzer_rd *f)
 {
     int delay_ms = (f->max_delay * (rand() % 1000)); 
-    if (status == APR_SUCCESS && delay_ms > 0) {
+    if (delay_ms > 0) {
         if (c->verbose > 0) {
             fprintf(stderr, "random-delay(%d): delaying conn %ld by %d ms\n", 
                     f->max_delay, c->id, delay_ms);
@@ -174,68 +134,100 @@ static apr_status_t rd_delay(h2c_conn *c
         apr_sleep(apr_time_from_msec(delay_ms));
     }
     ++f->count;
-    return status;
 }
 
-static apr_status_t rd_on_connect(h2c_conn *c, void *ctx)
+static apr_status_t rd_on_write(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rd *f = ctx;
-    return ((f->prev && f->prev->on_connect)? 
-            f->prev->on_connect(c, f->prev->ctx) : APR_SUCCESS);
+    if (c->written_bytes && c->buf_len > 0) {
+        rd_delay(c, obs->ctx);
+    }
+    return APR_SUCCESS;
 }
 
-static apr_status_t rd_on_read(h2c_conn *c, const char *data, apr_size_t len, void *ctx)
+static h2c_conn_obs *rd_create(const char *name, apr_pool_t *p)
 {
-    fuzzer_rd *f = ctx;
-    return ((f->prev && f->prev->on_read)? 
-            f->prev->on_read(c, data, len, f->prev->ctx) : APR_SUCCESS);
+    fuzzer_rd *f;
+    size_t prelen = sizeof("random-delay")-1;
+    
+    f = apr_pcalloc(p, sizeof(*f));
+    
+    f->name             = apr_pstrdup(p, name);
+    f->max_delay        = 5;
+    f->obs.ctx          = f;
+    f->obs.setup        = rd_setup;
+    f->obs.on_write     = rd_on_write;
+    
+    if (strlen(f->name) > prelen) {
+        int n = (int)apr_atoi64(f->name+prelen);
+        if (n > 0) {
+            f->max_delay = n;
+        }
+    }
+    return &f->obs;
 }
 
-static apr_status_t rd_on_write(h2c_conn *c, void *ctx)
-{
-    fuzzer_rd *f = ctx;
-    apr_status_t status = ((f->prev && f->prev->on_write)? 
-                    f->prev->on_write(c, f->prev->ctx) : APR_SUCCESS);
-    return (c->written_bytes && c->buf_len > 0)? rd_delay(c, f, status)
: status;
-}
+/*******************************************************************************
+ * stopping read on n-th call
+ ******************************************************************************/
+ 
+typedef struct fuzzer_sr {
+    h2c_conn_obs obs;
+    const char *name;
+    h2c_conn_obs *prev;
+    int delay_ms;
+    int n;
+    int i;
+} fuzzer_sr;
 
-static apr_status_t rd_before_close(h2c_conn *c, void *ctx)
+static h2c_conn_obs *sr_setup(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rd *f = ctx;
-    return ((f->prev && f->prev->before_close)? 
-            f->prev->before_close(c, f->prev->ctx) : APR_SUCCESS);
+    fuzzer_sr *fnew = apr_pcalloc(c->pool, sizeof(*fnew));
+    memcpy(fnew, obs->ctx, sizeof(*fnew));
+    fnew->obs.ctx = fnew;
+
+    return &fnew->obs;
 }
 
-static apr_status_t rd_before_shutdown(h2c_conn *c, void *ctx)
+static apr_status_t sr_before_read(h2c_conn *c, h2c_conn_obs *obs)
 {
-    fuzzer_rd *f = ctx;
-    return ((f->prev && f->prev->before_shutdown)? 
-            f->prev->before_shutdown(c, f->prev->ctx) : APR_SUCCESS);
+    fuzzer_sr *f = obs->ctx;
+    ++f->i;
+    if (f->i == f->n) {
+        if (c->verbose > 0) {
+            fprintf(stderr, "stop-read(%d-%d): call #%d\n", 
+                    f->n, f->delay_ms, f->i);
+        }
+        apr_sleep(apr_time_from_msec(f->delay_ms));
+        return APR_EAGAIN;
+    }
+    return APR_SUCCESS;
 }
 
-static h2c_conn_obs *rd_create(const char *name, apr_pool_t *p, h2c_conn_obs *prev)
+static h2c_conn_obs *sr_create(const char *name, apr_pool_t *p)
 {
-    fuzzer_rd *f;
-    size_t prelen = sizeof("random-delay")-1;
+    fuzzer_sr *f;
+    size_t prelen = sizeof("stop-read")-1;
     
     f = apr_pcalloc(p, sizeof(*f));
     
     f->name             = apr_pstrdup(p, name);
-    f->max_delay        = 5;
-    
+    f->delay_ms         = 5000;
+    f->n                = 10;
     f->obs.ctx          = f;
-    f->obs.setup        = rd_setup;
-    f->obs.on_connect   = rd_on_connect;
-    f->obs.on_read      = rd_on_read;
-    f->obs.on_write     = rd_on_write;
-    f->obs.before_shutdown = rd_before_shutdown;
-    f->obs.before_close = rd_before_close;
-    f->prev             = prev;
+    f->obs.before_read  = sr_before_read;
     
     if (strlen(f->name) > prelen) {
-        int n = (int)apr_atoi64(f->name+prelen);
+        const char *p = f->name + prelen;
+        int n = (int)apr_atoi64(p);
         if (n > 0) {
-            f->max_delay = n;
+            f->n = n;
+        }
+        p = strchr(p, '-');
+        if (p++) {
+            n = (int)apr_atoi64(p);
+            if (n > 0) {
+                f->delay_ms = n;
+            }
         }
     }
     return &f->obs;
@@ -245,15 +237,15 @@ static h2c_conn_obs *rd_create(const cha
  * delay submit of requests
  ******************************************************************************/
  typedef struct fuzzer_ds {
-    const char *name;
     h2c_session_obs obs;
-    h2c_session_obs *prev;
+    const char *name;
     int delay;
 } fuzzer_ds;
 
-static void ds_submit(h2c_session *s, h2c_stream *stream, h2c_request *r, void *ctx)
+static void ds_submit(h2c_session *s, h2c_stream *stream, h2c_request *r, 
+                      h2c_session_obs *obs)
 {
-    fuzzer_ds *f = ctx;
+    fuzzer_ds *f = obs->ctx;
     
     if (s->c->verbose > 1) {
         fprintf(stderr, "h2c_conn(%ld): submit %d delay %d ms\n", s->c->id, stream->id,
f->delay);
@@ -261,13 +253,9 @@ static void ds_submit(h2c_session *s, h2
     h2c_conn_flush(s->c);
     apr_sleep(apr_time_from_msec(f->delay));
     h2c_conn_read(s->c);
-    
-    return ((f->prev && f->prev->before_submit)? 
-            f->prev->before_submit(s, stream, r, f->prev->ctx) : APR_SUCCESS);
-    
 }
 
-static h2c_session_obs *ds_create(const char *name, apr_pool_t *p, h2c_session_obs *prev)
+static h2c_session_obs *ds_create(const char *name, apr_pool_t *p)
 {
     fuzzer_ds *f;
     size_t prelen = sizeof("submit-delay")-1;
@@ -276,10 +264,8 @@ static h2c_session_obs *ds_create(const
     
     f->name             = apr_pstrdup(p, name);
     f->delay            = 1;
-    
     f->obs.ctx          = f;
     f->obs.before_submit = ds_submit;
-    f->prev             = prev;
     
     if (strlen(f->name) > prelen) {
         int n = (int)apr_atoi64(f->name+prelen);
@@ -297,22 +283,25 @@ static h2c_session_obs *ds_create(const
 
 #define HAS_PREFIX(lit,cs)     (!strncmp((lit), (cs), sizeof(lit)-1))
 
-struct h2c_conn_obs *mh2f_conn_fuzzer_create(const char *name, apr_pool_t *p, h2c_conn_obs
*prev)
+struct h2c_conn_obs *mh2f_conn_fuzzer_create(const char *name, apr_pool_t *p)
 {
+    h2c_conn_obs *obs;
     if (HAS_PREFIX("random-close", name)) {
-        return rc_create(name, p, prev);
+        obs = rc_create(name, p);
     }
     else if (HAS_PREFIX("random-delay", name)) {
-        return rd_create(name, p, prev);
+        obs = rd_create(name, p);
     }
-    return NULL;
+    else if (HAS_PREFIX("stop-read", name)) {
+        obs = sr_create(name, p);
+    }
+    return obs;
 }
 
-struct h2c_session_obs *mh2f_session_fuzzer_create(const char *name, apr_pool_t *p, 
-                                                   struct h2c_session_obs *prev)
+struct h2c_session_obs *mh2f_session_fuzzer_create(const char *name, apr_pool_t *p)
 {
     if (HAS_PREFIX("submit-delay", name)) {
-        return ds_create(name, p, prev);
+        return ds_create(name, p);
     }
     return NULL;
 }

Modified: httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.h
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.h?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/mh2f_fuzzer.h Tue Feb  2 12:18:48 2016
@@ -19,9 +19,7 @@
 struct h2c_conn_obs;
 struct h2c_session_obs;
 
-struct h2c_conn_obs *mh2f_conn_fuzzer_create(const char *name, apr_pool_t *p, 
-                                             struct h2c_conn_obs *prev);
-struct h2c_session_obs *mh2f_session_fuzzer_create(const char *name, apr_pool_t *p, 
-                                                   struct h2c_session_obs *prev);
+struct h2c_conn_obs *mh2f_conn_fuzzer_create(const char *name, apr_pool_t *p);
+struct h2c_session_obs *mh2f_session_fuzzer_create(const char *name, apr_pool_t *p);
 
 #endif /* mh2f_fuzzer_h */

Modified: httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c?rev=1728097&r1=1728096&r2=1728097&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c Tue Feb  2 12:18:48 2016
@@ -93,8 +93,8 @@ int main(int argc, char **argv)
     h2c_session *session;
     h2c_request **r;
     size_t rlen;
-    h2c_conn_obs *conn_fuzzer = NULL;
-    h2c_session_obs *session_fuzzer = NULL;
+    h2c_conn_obs *conn_fuzzer = NULL, *cobs;
+    h2c_session_obs *session_fuzzer = NULL, *sobs;
     void *v;
     apr_thread_t **threads;
     apr_threadattr_t *thread_attr;
@@ -120,14 +120,16 @@ int main(int argc, char **argv)
                 connections = (int)apr_atoi64(optarg);
                 break;
             case 'f':
-                v = mh2f_conn_fuzzer_create(optarg, pool, conn_fuzzer);
-                if (v) {
-                    conn_fuzzer = v;
+                cobs = mh2f_conn_fuzzer_create(optarg, pool);
+                if (cobs) {
+                    cobs->next = conn_fuzzer;
+                    conn_fuzzer = cobs;
                 }
                 else {
-                    v = mh2f_session_fuzzer_create(optarg, pool, session_fuzzer);
-                    if (v) {
-                        session_fuzzer = v;
+                    sobs = mh2f_session_fuzzer_create(optarg, pool);
+                    if (sobs) {
+                        sobs->next = session_fuzzer;
+                        session_fuzzer = sobs;
                     }
                     else {
                         fprintf(stderr, "unknown fuzzer '%s'\n", optarg);




Mime
View raw message