else
atmost = bufferevent_get_write_max_(&bev_ssl->bev);
+ if (bev_ssl->flags & BUFFEREVENT_SSL_BATCH_WRITE) {
+ /* Try to send as many as we can to avoid Nagle effect */
+ evbuffer_pullup(output, -1);
+ }
+
n = evbuffer_peek(output, atmost, NULL, space, 8);
if (n < 0)
return OP_ERR | result;
ev_uint64_t old_flags = EV_UINT64_MAX;
struct bufferevent_ssl *bev_ssl;
- flags &= (BUFFEREVENT_SSL_DIRTY_SHUTDOWN);
+ flags &= (BUFFEREVENT_SSL_DIRTY_SHUTDOWN|BUFFEREVENT_SSL_BATCH_WRITE);
if (!flags)
return old_flags;
ev_uint64_t old_flags = EV_UINT64_MAX;
struct bufferevent_ssl *bev_ssl;
- flags &= (BUFFEREVENT_SSL_DIRTY_SHUTDOWN);
+ flags &= (BUFFEREVENT_SSL_DIRTY_SHUTDOWN|BUFFEREVENT_SSL_BATCH_WRITE);
if (!flags)
return old_flags;
not to use SSL 2.)
*/
#define BUFFEREVENT_SSL_DIRTY_SHUTDOWN 1
+/** Control writes in the SSL bufferevents.
+
+ By default SSL bufferevent will peek bytes from the buffer as the arrived.
+ with respect to the segment boundaries in the buffer.
+ However, by ignoring these segment boundaries number of packets to send
+ can be decreased.
+
+ This flags will ignore the segment boundaries.
+
+ Useful in conjunction with http layer.
+*/
+#define BUFFEREVENT_SSL_BATCH_WRITE 2
#if defined(EVENT__HAVE_OPENSSL) || defined(EVENT_IN_DOXYGEN_)
/* This is what openssl's SSL objects are underneath. */
REGRESS_OPENSSL_CLIENT_WRITE = 2048,
REGRESS_DEFERRED_CALLBACKS = 4096,
+
+ REGRESS_OPENSSL_BATCH_WRITE = 8192,
};
static void
bufferevent_ssl_set_allow_dirty_shutdown(*bev1_out, dirty_shutdown);
bufferevent_ssl_set_allow_dirty_shutdown(*bev2_out, dirty_shutdown);
+
+ if (REGRESS_OPENSSL_BATCH_WRITE) {
+ bufferevent_ssl_set_flags(*bev1_out, BUFFEREVENT_SSL_BATCH_WRITE);
+ bufferevent_ssl_set_flags(*bev2_out, BUFFEREVENT_SSL_BATCH_WRITE);
+ }
}
static void
#define T(a) ((void *)(a))
{ "bufferevent_socketpair", regress_bufferevent_openssl,
TT_ISOLATED, &ssl_setup, T(REGRESS_OPENSSL_SOCKETPAIR) },
+ { "bufferevent_socketpair_batch_write", regress_bufferevent_openssl,
+ TT_ISOLATED, &ssl_setup, T(REGRESS_OPENSSL_SOCKETPAIR | REGRESS_OPENSSL_BATCH_WRITE) },
{ "bufferevent_socketpair_write_after_connect", regress_bufferevent_openssl,
TT_ISOLATED, &ssl_setup,
T(REGRESS_OPENSSL_SOCKETPAIR|REGRESS_OPENSSL_CLIENT_WRITE) },