Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

multiple nc request in keepalive fails to increase keepalive count #149

Open
tturbs opened this issue Dec 31, 2019 · 1 comment
Open

multiple nc request in keepalive fails to increase keepalive count #149

tturbs opened this issue Dec 31, 2019 · 1 comment

Comments

@tturbs
Copy link

tturbs commented Dec 31, 2019

Details

multiple nc request in keepalive fails to increase keepalive count.

Steps or code to reproduce the problem.

diff --git a/examples/test_proxy.c b/examples/test_proxy.c
index daba6e5..9a2c8ef 100644
--- a/examples/test_proxy.c
+++ b/examples/test_proxy.c
@@ -45,7 +45,8 @@ backend_cb(evhtp_request_t * backend_req, void * arg) {
     evhtp_request_t * frontend_req = (evhtp_request_t *)arg;

     evbuffer_prepend_buffer(frontend_req->buffer_out, backend_req->buffer_in);
-    evhtp_headers_add_headers(frontend_req->headers_out, backend_req->headers_in);
+    /* evhtp_headers_add_headers(frontend_req->headers_out, backend_req->headers_in); */
+

     /*
      * char body[1024] = { '\0' };
@@ -53,6 +54,7 @@ backend_cb(evhtp_request_t * backend_req, void * arg) {
      * printf("Backend %zu: %s\n", len, body);
      */

+    printf("yongk: %lu\n", frontend_req->conn->num_requests);
     evhtp_send_reply(frontend_req, EVHTP_RES_OK);
     evhtp_request_resume(frontend_req);
 }

build and run

$ gcc -I../include/ -I../build/include -pthread -lssl -lcrypto test_proxy.c -levent -levent_openssl -levent_pthreads ../build/libevhtp.a
$ ./a.out

reproduce

  1. copy next to clipboard
GET / HTTP/1.1

GET / HTTP/1.1

GET / HTTP/1.1

GET / HTTP/1.1

  1. Run nc and past it multiple times
$ nc -C localhost 8081
  1. server print result
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 0
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 0
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 0
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 0
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 1
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 1
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 1
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 1
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 2
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 2
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 2
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.
yongk: 2
  Received frontend request on thread 8... Making backend request...
Ok.
Ok.

Example code (if applicable)

Version

tag: 1.2.18

@tturbs
Copy link
Author

tturbs commented Dec 31, 2019

Here might cause this problem. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant