You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2016/01/06 15:36:17 UTC

svn commit: r1723334 - in /httpd/test/mod_h2/trunk: Makefile.am mh2fuzz/Makefile.am mh2fuzz/h2c_conn.c mh2fuzz/h2c_conn.h mh2fuzz/h2c_session.c mh2fuzz/h2c_stream.c mh2fuzz/h2c_worker.c mh2fuzz/h2c_worker.h mh2fuzz/mh2f_main.c

Author: icing
Date: Wed Jan  6 14:36:16 2016
New Revision: 1723334

URL: http://svn.apache.org/viewvc?rev=1723334&view=rev
Log:
mh2fuzz now talks tls, shutdown improved to read last frames from server

Modified:
    httpd/test/mod_h2/trunk/Makefile.am
    httpd/test/mod_h2/trunk/mh2fuzz/Makefile.am
    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_stream.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c
    httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.h
    httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c

Modified: httpd/test/mod_h2/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/Makefile.am?rev=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/Makefile.am (original)
+++ httpd/test/mod_h2/trunk/Makefile.am Wed Jan  6 14:36:16 2016
@@ -93,6 +93,11 @@ restart: $(SERVER_DIR)/.test-setup
 	@-test -x "$(PHP_FPM)" && test ! -f "$(PHP_FPM_PID)" && \
         "$(PHP_FPM)" --prefix gen/php-fpm && echo "php-fpm started"
 
+reload: $(SERVER_DIR)/.test-setup
+	@echo -n reloading httpd...
+	@$(APACHECTL) -k graceful
+	@echo done.
+
 stop:
 	@-test -f "$(PHP_FPM_PID)" && kill "$$( cat $(PHP_FPM_PID) )" || echo "php-fpm not running"
 	$(APACHECTL) -k stop
@@ -115,8 +120,7 @@ install: install-mh2fuzz @INSTALL_DEP@
 TESTRUN = PREFIX=$(prefix) NGHTTP=$(NGHTTP) CURL=$(CURL) APXS=$(APXS) bash
 
 test: \
-		$(SERVER_DIR)/.test-setup \
-		$(SERVER_DIR)/.curl-installed
+		$(SERVER_DIR)/.test-setup
 	@rm -rf $(GEN)/tmp
 	@mkdir -p $(GEN)/tmp
 	$(TESTRUN) test/test.sh test $(HTTP_PORT) $(HTTPS_PORT) $(HOST_NAME) $(HOST_NAME_2) $(HOST_SER_NAME)
@@ -142,7 +146,6 @@ MAX_STREAMS = 100
 
 h2load: \
 		$(SERVER_DIR)/.test-setup \
-		$(SERVER_DIR)/.curl-installed \
         $(GEN)/load-urls-1.txt
 	$(H2LOAD) -c 100 -t 10 -n 100000 -m $(MAX_STREAMS) https://$(HTTPS_AUTH)/index.html
 	$(H2LOAD) -i $(GEN)/load-urls-1.txt -n 200000 -t 1 -m $(MAX_STREAMS) -c 8
@@ -158,7 +161,6 @@ h2load: \
 
 h2cload: \
 		$(SERVER_DIR)/.test-setup \
-		$(SERVER_DIR)/.curl-installed \
         $(GEN)/load-h2c-urls-1.txt
 	$(H2LOAD) -c 100 -t 10 -n 100000 -m $(MAX_STREAMS) http://$(HTTP_AUTH)/index.html
 	$(H2LOAD) -i $(GEN)/load-h2c-urls-1.txt -n 200000 -t 1 -m $(MAX_STREAMS) -c 8
@@ -231,6 +233,8 @@ $(SERVER_DIR)/.testdocs-setup: \
 
 $(SERVER_DIR)/.test-setup: \
         Makefile \
+		$(SERVER_DIR)/.curl-installed \
+		mh2fuzz/mmh2fuzz \
 		conf/*.conf \
         bin/* \
         conf/mods-available/*.* \
@@ -324,3 +328,10 @@ $(GEN)/php-fpm/.setup: \
 #
 $(SERVER_DIR)/.curl-installed:
 	make -C clients
+    
+################################################################################
+# mh2fuzz 
+#
+mh2fuzz/mmh2fuzz: mh2fuzz/*.*
+	make -C mh2fuzz
+

Modified: httpd/test/mod_h2/trunk/mh2fuzz/Makefile.am
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/Makefile.am?rev=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/Makefile.am (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/Makefile.am Wed Jan  6 14:36:16 2016
@@ -18,7 +18,7 @@ ACLOCAL_AMFLAGS = -I m4
 AUTOMAKE_OPTIONS = foreign
 
 CFLAGS= -g
-LDFLAGS=-L@LIB_DIR@ -lapr-1 -laprutil-1
+LDFLAGS=-L@LIB_DIR@ -lapr-1 -laprutil-1 -lssl -lcrypto
 
 bin_PROGRAMS = mh2fuzz
 

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=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.c Wed Jan  6 14:36:16 2016
@@ -16,10 +16,13 @@
 #include <apr.h>
 #include <apr_strings.h>
 #include <apr_poll.h>
+#include <apr_portable.h>
 #include <apr_time.h>
 #include <apr_uri.h>
 
 #include <nghttp2/nghttp2.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
 
 #include "h2c_conn.h"
 #include "h2c_util.h"
@@ -83,7 +86,127 @@ static apr_status_t write_plain(h2c_conn
     return status;
 }
 
-apr_status_t h2c_conn_create(h2c_conn **pc, apr_pool_t *parent, apr_uri_t *uri)
+static apr_status_t tls_read(h2c_conn *c) {
+    apr_status_t status = APR_SUCCESS, s2;
+    int rv;
+    char buffer[16*1024];
+    apr_size_t len = H2_DIM(buffer);
+
+    ERR_clear_error();
+    if (!c->socket) {
+        return APR_EOF;
+    }
+    rv = SSL_read(c->ssl, buffer, len);
+    if (rv <= 0) {
+        int err = SSL_get_error(c->ssl, rv);
+        switch (err) {
+            case SSL_ERROR_WANT_READ:
+                h2c_conn_want_io(c, H2C_CONN_READ);
+                return APR_SUCCESS;
+            case SSL_ERROR_WANT_WRITE:
+                // renegotiation started
+                h2c_conn_want_io(c, H2C_CONN_WRITE);
+                return APR_EAGAIN;
+            default:
+                fprintf(stderr, "tls error reading %d", err);
+                h2c_conn_close(c);
+                return APR_EGENERAL;
+        }
+    }
+    
+    s2 = on_read(c, buffer, rv);
+    if (status == APR_SUCCESS) {
+        status = s2;
+    }
+    return status;
+}
+
+static apr_status_t tls_write(h2c_conn *c) {
+    apr_status_t status = APR_SUCCESS;
+    int rv;
+    
+    ERR_clear_error();
+    if (!c->socket) {
+        return APR_EOF;
+    }
+    if (c->buf_len > 0) {
+        rv = SSL_write(c->ssl, c->buffer + c->buf_head, c->buf_len);
+        if (rv <= 0) {
+            int err = SSL_get_error(c->ssl, rv);
+            switch (err) {
+                case SSL_ERROR_WANT_READ:
+                    // renegotiation started
+                    h2c_conn_want_io(c, H2C_CONN_READ);
+                    return APR_EAGAIN;
+                case SSL_ERROR_WANT_WRITE:
+                    h2c_conn_want_io(c, H2C_CONN_WRITE);
+                    return APR_SUCCESS;
+                default:
+                    fprintf(stderr, "tls error writing %d", err);
+                    h2c_conn_close(c);
+                    return APR_EGENERAL;
+            }
+        }
+        c->buf_head += rv;
+        c->buf_len -= rv;
+        c->written_bytes += rv;
+    }
+    
+    return status;
+}
+
+static apr_status_t connected(h2c_conn *c) 
+{
+    if (c->ssl) {
+        const char *proto;
+        unsigned int proto_len;
+        SSL_get0_alpn_selected(c->ssl, (const unsigned char **)&proto, &proto_len);
+        proto = apr_pstrndup(c->pool, proto, proto_len);
+        if (strcmp("h2", proto)) {
+            fprintf(stderr, "error, ALPN did not select 'h2', but %s\n", proto);
+            h2c_conn_close(c);
+        }
+        if (c->verbose) {
+            fprintf(stderr, "ALPN: selected %s\n", proto);
+        }
+    }
+    
+    if (c->obs && c->obs->on_connect) {
+        return c->obs->on_connect(c, c->obs->ctx);
+    }
+    return APR_SUCCESS;
+}
+
+static apr_status_t tls_handshake(h2c_conn *c) {
+    int rv;
+    
+    ERR_clear_error();
+    rv = SSL_do_handshake(c->ssl);
+
+    if (rv <= 0) {
+        int err = SSL_get_error(c->ssl, rv);
+        switch (err) {
+            case SSL_ERROR_WANT_READ:
+                h2c_conn_want_io(c, H2C_CONN_READ);
+                return APR_SUCCESS;
+            case SSL_ERROR_WANT_WRITE:
+                h2c_conn_want_io(c, H2C_CONN_WRITE);
+                return APR_SUCCESS;
+            default:
+                fprintf(stderr, "tls handshake error %d", err);
+                h2c_conn_close(c);
+                return APR_EGENERAL;
+        }
+    }
+    
+    c->read = tls_read;
+    c->write = tls_write;
+    
+    return connected(c);
+}
+
+apr_status_t h2c_conn_create(h2c_conn **pc, apr_pool_t *parent, 
+                             apr_uri_t *uri, void *ssl_ctx)
 {
     apr_pool_t *p;
     apr_status_t status;
@@ -130,9 +253,23 @@ apr_status_t h2c_conn_create(h2c_conn **
     c->pfd = apr_pcalloc(p, sizeof *c->pfd);
     c->pfd->desc_type   = APR_POLL_SOCKET;
     c->pfd->desc.s      = c->socket;
-    c->pfd->reqevents   = APR_POLLIN|APR_POLLOUT;
     c->pfd->client_data = c;
 
+    if (!strcmp("https", uri->scheme)) {
+        apr_os_sock_t sfd;
+        
+        apr_os_sock_get(&sfd, c->socket);
+        c->ssl = SSL_new(ssl_ctx);
+        SSL_set_tlsext_host_name(c->ssl, uri->hostname);
+        SSL_set_fd(c->ssl, sfd);
+        SSL_set_connect_state(c->ssl);
+
+        c->read           = tls_handshake;
+        c->write          = tls_handshake;
+    }
+    
+    h2c_conn_want_io(c, H2C_CONN_READ|H2C_CONN_WRITE);
+    
     *pc = c;
     
     return APR_SUCCESS;
@@ -140,6 +277,11 @@ apr_status_t h2c_conn_create(h2c_conn **
 
 void h2c_conn_destroy(h2c_conn *c)
 {
+    if (c->ssl) {
+        SSL_free(c->ssl);
+        c->ssl = NULL;
+    }
+    
     if (c->socket) {
         apr_socket_close(c->socket);
         c->socket = NULL;
@@ -186,7 +328,7 @@ apr_status_t h2c_conn_connect(h2c_conn *
     apr_status_t status;
     
     if (c->verbose > 0) {
-        printf("connecting to %s (%s)...", c->addr->hostname, c->ip_addr);
+        fprintf(stderr, "connecting to %s (%s)...", c->addr->hostname, c->ip_addr);
     }
     
     apr_socket_timeout_set(c->socket, apr_time_from_sec(10));
@@ -197,14 +339,12 @@ apr_status_t h2c_conn_connect(h2c_conn *
     
     apr_socket_timeout_set(c->socket, apr_time_from_sec(60));
     if (c->verbose > 0) {
-        printf("done.\n");
+        fprintf(stderr, "done.\n");
     }
     
     apr_socket_opt_set(c->socket, APR_SO_NONBLOCK, 1);
-    if (c->obs && c->obs->on_connect) {
-        return c->obs->on_connect(c, c->obs->ctx);
-    }
-    return APR_SUCCESS;
+    
+    return c->ssl? APR_SUCCESS : connected(c);
 }
 
 apr_status_t h2c_conn_read(h2c_conn *c)
@@ -218,16 +358,46 @@ apr_status_t h2c_conn_write(h2c_conn *c)
     return c->write(c);
 }
 
-apr_status_t h2c_conn_close(h2c_conn *c)
+apr_status_t h2c_conn_shutdown(h2c_conn *c)
+
 {
     apr_status_t status = APR_SUCCESS;
     
-    if (c->socket) {
+    if (c->socket && !c->shutdown) {
         if (c->obs && c->obs->before_close) {
             c->obs->before_close(c, c->obs->ctx);
         }
-        status = apr_socket_close(c->socket);
-        c->socket = NULL;
+        
+        status = c->write(c);
+        status = apr_socket_shutdown(c->socket, APR_SHUTDOWN_WRITE);
+        c->shutdown = 1;
+        h2c_conn_want_io(c, H2C_CONN_READ);
+    }
+    return status;
+}
+
+apr_status_t h2c_conn_close(h2c_conn *c)
+{
+    apr_status_t status = APR_SUCCESS;
+    
+    if (c->socket) {
+        if (!c->shutdown) {
+            status = h2c_conn_shutdown(c);
+        }
+        
+        if (c->ssl) {
+            SSL_set_shutdown(c->ssl, SSL_RECEIVED_SHUTDOWN);
+            ERR_clear_error();
+            if (SSL_shutdown(c->ssl) != 1) {
+                SSL_free(c->ssl);
+                c->ssl = NULL;
+            }
+        }
+        
+        if (status == APR_SUCCESS) {
+            status = apr_socket_close(c->socket);
+            c->socket = NULL;
+        }
     }
     return status;
 }

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=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_conn.h Wed Jan  6 14:36:16 2016
@@ -48,6 +48,7 @@ struct h2c_conn {
     apr_sockaddr_t         *addr;
     const char             *ip_addr;
     apr_socket_t           *socket;
+    void                   *ssl;
     
     h2c_conn_action        *read;
     h2c_conn_action        *write;
@@ -61,10 +62,12 @@ struct h2c_conn {
     apr_off_t              read_bytes;
     
     h2c_conn_obs           *obs;
+    unsigned int           shutdown : 1;
     int                    verbose;
 };
 
-apr_status_t h2c_conn_create(h2c_conn **pc, apr_pool_t *parent, apr_uri_t *uri);
+apr_status_t h2c_conn_create(h2c_conn **pc, apr_pool_t *parent, 
+                             apr_uri_t *uri, void *ssl_ctx);
 
 void h2c_conn_destroy(h2c_conn *c);
 
@@ -81,6 +84,7 @@ apr_status_t h2c_conn_connect(h2c_conn *
 apr_status_t h2c_conn_read(h2c_conn *c);
 apr_status_t h2c_conn_write(h2c_conn *c);
 
+apr_status_t h2c_conn_shutdown(h2c_conn *c);
 apr_status_t h2c_conn_close(h2c_conn *c);
 
 apr_size_t h2c_conn_wbuf_left(h2c_conn *c);

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=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_session.c Wed Jan  6 14:36:16 2016
@@ -61,7 +61,7 @@ apr_status_t h2c_session_create(h2c_sess
 
 static apr_status_t h2c_session_close(h2c_session *s)
 {
-    if (!s->closed) {
+    if (!s->closed && s->ngh2) {
         if (!s->goaway_recvd) {
             nghttp2_submit_goaway(s->ngh2, NGHTTP2_FLAG_NONE, 
                                   s->max_stream_recv, 0, NULL, 0);
@@ -179,7 +179,7 @@ static int on_frame_recv(nghttp2_session
                 fprintf(stderr, "%ld: recv GOAWAY, err=%d\n", s->c->id,
                         frame->goaway.error_code);
             }
-            h2c_session_close(s);
+            h2c_conn_close(s->c);
             break;
         default:
             break;
@@ -220,33 +220,35 @@ static apr_status_t check_io_sense(h2c_s
 {
     int io_sense = 0;
 
-    if (status == APR_SUCCESS && s->feed && s->max_streams > s->open_streams) {
-        apr_status_t s2;
-        h2c_request *r;
+    if (s->ngh2) {
+        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_conn_shutdown(s->c);
+                status = APR_EOF;
+            }
+        }
         
-        s2 = h2c_feed_next(&r, s->feed, s);
-        if (s2 == APR_SUCCESS) {
-            status = h2c_session_submit(s, r, NULL);
+        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;
         }
-        else if (APR_STATUS_IS_EOF(s2) && s->open_streams == 0) {
-            io_sense |= H2C_CONN_READ;
-            h2c_session_close(s);
-            status = APR_EOF;
+        if (!io_sense) {
+            return 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);
     }
     
-    h2c_conn_want_io(s->c, io_sense);
     return status;
 }
 
@@ -256,7 +258,7 @@ static int on_stream_close(nghttp2_sessi
     h2c_session *s = user_data;
     h2c_stream *stream;
     
-    if (s->c->verbose > 0) {
+    if (s->c->verbose > 1) {
         fprintf(stderr, "closed STREAM[%d]\n", stream_id);
     }
     
@@ -299,25 +301,29 @@ static apr_status_t on_conn_read(h2c_con
 {
     h2c_session *s = ctx;
     
-    ssize_t rv = nghttp2_session_mem_recv(s->ngh2, (const uint8_t*)data, len);
-    if (rv < 0) {
-        return APR_ECONNRESET;
+    if (s->ngh2) {
+        ssize_t rv = nghttp2_session_mem_recv(s->ngh2, (const uint8_t*)data, len);
+        if (rv < 0) {
+            return APR_ECONNRESET;
+        }
+        return check_io_sense(s, APR_SUCCESS);
     }
-    
-    return check_io_sense(s, APR_SUCCESS);
+    return APR_SUCCESS;
 }
 
 static apr_status_t on_conn_write(h2c_conn *c, void *ctx)
 {
     h2c_session *s = ctx;
-    apr_status_t status = APR_SUCCESS;
-    int rv = nghttp2_session_send(s->ngh2);
     
-    if (rv != 0) {
-        return APR_ECONNRESET;
+    if (s->ngh2) {
+        int rv = nghttp2_session_send(s->ngh2);
+        
+        if (rv != 0) {
+            return APR_ECONNRESET;
+        }
+        return check_io_sense(s, APR_SUCCESS);
     }
-    
-    return check_io_sense(s, status);
+    return APR_SUCCESS;
 }
 
 static apr_status_t on_conn_connect(h2c_conn *c, void *ctx)

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_stream.c
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_stream.c?rev=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_stream.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_stream.c Wed Jan  6 14:36:16 2016
@@ -72,7 +72,7 @@ apr_status_t h2c_stream_close(h2c_stream
     if (!stream->closed) {
         stream->closed = 1;
         if (stream->s->c->verbose >= 0) {
-            fprintf(stderr, "%5ld:%05d %s %s -> %d %ld\n", 
+            fprintf(stderr, "--> %5ld:%05d %s %s -> %d %ld\n", 
                     stream->s->c->id, stream->id, 
                     stream->r->method, stream->r->path,
                     stream->response->status, (long)stream->response->recv_bytes);

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=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.c Wed Jan  6 14:36:16 2016
@@ -26,6 +26,7 @@
 static int nid;
 
 apr_status_t h2c_worker_create(h2c_worker **pw, apr_pool_t *p, apr_uri_t *uri, 
+                               void *ssl_ctx,
                                h2c_feed *feed, h2c_conn_obs *conn_fuzzer,
                                int num_conns, int max_streams, int verbose)
 {
@@ -36,6 +37,7 @@ apr_status_t h2c_worker_create(h2c_worke
     w->id          = nid++;
     w->p           = p;
     w->uri         = uri;
+    w->ssl_ctx     = ssl_ctx;
     w->feed        = feed;
     w->conn_fuzzer = conn_fuzzer;
     w->max_streams = max_streams;
@@ -76,7 +78,7 @@ apr_status_t h2c_worker_run(h2c_worker *
         h2c_conn *conn;
         h2c_session *session;
         
-        status = h2c_conn_create(&conn, w->p, w->uri);
+        status = h2c_conn_create(&conn, w->p, w->uri, w->ssl_ctx);
         if (status != APR_SUCCESS) {
             fprintf(stderr, "error %d creating conn %s\n", status, w->uri->hostname);
             return status;
@@ -163,7 +165,7 @@ apr_status_t h2c_worker_run(h2c_worker *
                 if (!APR_STATUS_IS_EOF(status)) {
                     fprintf(stderr, "closing %ld, status %d %s\n", c->id, status, op);
                 }
-                h2c_conn_close(c);
+                h2c_conn_shutdown(c);
             }
             
             if (!c->socket) {

Modified: httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.h
URL: http://svn.apache.org/viewvc/httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.h?rev=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.h (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/h2c_worker.h Wed Jan  6 14:36:16 2016
@@ -26,6 +26,7 @@ struct h2c_worker {
     int id;
     apr_pool_t *p;
     apr_uri_t *uri;
+    void *ssl_ctx;
     struct h2c_feed *feed;
     struct h2c_conn_obs *conn_fuzzer;
     
@@ -35,7 +36,8 @@ struct h2c_worker {
     int verbose;
 };
 
-apr_status_t h2c_worker_create(h2c_worker **pw, apr_pool_t *p, apr_uri_t *uri,
+apr_status_t h2c_worker_create(h2c_worker **pw, apr_pool_t *p, apr_uri_t *uri, 
+                               void *ssl_ctx,
                                struct h2c_feed *feed, struct h2c_conn_obs *conn_fuzzer,
                                int num_conns, int max_streams, int verbose);
 

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=1723334&r1=1723333&r2=1723334&view=diff
==============================================================================
--- httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c (original)
+++ httpd/test/mod_h2/trunk/mh2fuzz/mh2f_main.c Wed Jan  6 14:36:16 2016
@@ -20,6 +20,8 @@
 #include <apr_strings.h>
 #include <apr_thread_proc.h>
 
+#include <openssl/ssl.h>
+
 #include "h2c_conn.h"
 #include "h2c_feed.h"
 #include "h2c_request.h"
@@ -44,10 +46,11 @@ static int usage(const char *cmd, const
     return 2;
 }
 
-static apr_thread_t *worker_create(apr_pool_t *parent, apr_uri_t *uri, 
+static apr_thread_t *worker_create(apr_pool_t *parent, apr_uri_t *uri, SSL_CTX *ssl_ctx, 
                                    h2c_feed *feed, h2c_conn_obs *conn_fuzzer, 
                                    int num_conns, int max_streams, int verbose,
                                    apr_threadattr_t *attr);
+static SSL_CTX *setup_ssl_ctx(void);
 
 static struct option long_options[] = {
     { "connections",           required_argument, NULL, 'c'},
@@ -84,6 +87,7 @@ int main(int argc, char **argv)
     apr_thread_t **threads;
     apr_threadattr_t *thread_attr;
     h2c_feed **feeds;
+    SSL_CTX *ssl_ctx;
     
     apr_pool_initialize();
     apr_pool_create_core(&pool);
@@ -162,6 +166,7 @@ int main(int argc, char **argv)
         uri.scheme = "https";
     }
     
+    ssl_ctx = setup_ssl_ctx();
         
     if (!uri.port_str) {
         uri.port = apr_uri_port_of_scheme(uri.scheme);
@@ -197,7 +202,7 @@ int main(int argc, char **argv)
         
         h2c_feed_repeat_create(&feed, pool, r, n);
         feeds[i] = feed;
-        threads[i] = worker_create(pool, &uri, feed, conn_fuzzer, 
+        threads[i] = worker_create(pool, &uri, ssl_ctx, feed, conn_fuzzer, 
                                    num_conns, max_streams, verbose,
                                    thread_attr);
     }
@@ -228,6 +233,8 @@ int main(int argc, char **argv)
                 (long)summary.resp_500s, (long)summary.resp_none);
     }
     
+    SSL_CTX_free(ssl_ctx);
+
     return (status == APR_SUCCESS)? 0 : 1;
 }
 
@@ -242,6 +249,7 @@ static void* APR_THREAD_FUNC execute(apr
 }
 
 static apr_thread_t *worker_create(apr_pool_t *parent, apr_uri_t *uri, 
+                                   SSL_CTX *ssl_ctx,
                                    h2c_feed *feed, h2c_conn_obs *conn_fuzzer, 
                                    int num_conns, int max_streams, int verbose,
                                    apr_threadattr_t *attr)
@@ -256,7 +264,7 @@ static apr_thread_t *worker_create(apr_p
     apr_pool_create_ex(&pool, parent, NULL, allocator);
     apr_allocator_owner_set(allocator, pool);
 
-    status = h2c_worker_create(&w, pool, uri, feed, conn_fuzzer,
+    status = h2c_worker_create(&w, pool, uri, ssl_ctx, feed, conn_fuzzer, 
                                num_conns, max_streams, verbose);
     if (status != APR_SUCCESS) {
         fprintf(stderr, "error %d creating worker\n", status);
@@ -267,3 +275,38 @@ static apr_thread_t *worker_create(apr_p
     return t;
 }
 
+static const unsigned char alpn_protos[] = {
+    2, 'h', '2'
+};
+
+static SSL_CTX *setup_ssl_ctx(void)
+{
+    const char *ciphers;
+    SSL_CTX *ctx;
+    
+    SSL_load_error_strings();
+    SSL_library_init();
+    OpenSSL_add_all_algorithms();
+
+    ctx = SSL_CTX_new(SSLv23_client_method());
+    if (!ctx) {
+        fprintf(stderr, "unable to create SSL context\n");
+        exit(1);
+    }
+    
+    SSL_CTX_set_options(ctx, (SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) |
+                        SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION |
+                        SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
+    SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
+    SSL_CTX_set_mode(ctx, SSL_MODE_RELEASE_BUFFERS);
+
+    ciphers = SSL_DEFAULT_CIPHER_LIST;
+    if (SSL_CTX_set_cipher_list(ctx, ciphers) == 0) {
+        fprintf(stderr, "unable to set cipher list %s\n", ciphers);
+        exit(1);
+    }
+    
+    SSL_CTX_set_alpn_protos(ctx, alpn_protos, sizeof(alpn_protos));
+    
+    return ctx;
+}