Open aflin opened 4 years ago
Actually the problem doesn't go away with the above edit when buffer_out size is more than about 800 bytes. My guess is that performance is degraded when the buffer is fragmented and ssl is on. This is a simpler fix and seems to work with larger buffer_out sizes:
static struct evbuffer *
htp__create_reply_(evhtp_request_t * request, evhtp_res code)
{
struct evbuffer * buf;
...
evhtp_headers_for_each(request->headers_out, htp__create_headers_, buf);
evbuffer_add(buf, "\r\n", 2);
if (evbuffer_get_length(request->buffer_out)) {
evbuffer_add_buffer(buf, request->buffer_out);
if (request->conn->htp->ssl_ctx != NULL)
evbuffer_pullup(buf,-1);
}
return buf;
} /* htp__create_reply_ */
First: Thanks for the library!
Details
Steps or code to reproduce the problem.
In the examples/https/example_https_server.c I added a call to evbuffer_add:
Benchmarking the difference: Before adding the body text:
After adding the body text:
This only occurs when enabling https. As a quick fix, I made the following changes to htp__createreply
Maybe I'm doing something wrong? If not, I'm guessing the problem is in libevent. However, since I'm only tracking down the problem this far, I'm reporting it here. Hoping you can come up with a better solution than the multiple copies I'm doing.