Discussion:
Purpose of use_wrapper in le-proxy.c?
(too old to reply)
Jeffrey Walton
2014-02-24 18:24:13 UTC
Permalink
Raw Message
samples/le-proxy.c has a `use_wrapper` flag. Its used in, for example,
`accept_cb` (parts shown below). I don't quite understand its purpose.

There's also a `use_ssl` and that's tied to `ssl_ctx` (and the source
code mkes some decisions around `ssl_ctx`, which makes sense to me).

What is the purpose of `use_wrapper`?

Thanks in advance.

*****


if (!ssl_ctx || use_wrapper)
b_out = bufferevent_socket_new(base, -1,
BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS);
else {
SSL *ssl = SSL_new(ssl_ctx);
b_out = bufferevent_openssl_socket_new(base, -1, ssl,
BUFFEREVENT_SSL_CONNECTING,
BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS);
}
...

if (ssl_ctx && use_wrapper) {
struct bufferevent *b_ssl;
SSL *ssl = SSL_new(ssl_ctx);
b_ssl = bufferevent_openssl_filter_new(base,
b_out, ssl, BUFFEREVENT_SSL_CONNECTING,
BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS);
if (!b_ssl) {
perror("Bufferevent_openssl_new");
bufferevent_free(b_out);
bufferevent_free(b_in);
}
b_out = b_ssl;
}
...
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Nick Mathewson
2014-02-24 19:30:50 UTC
Permalink
Raw Message
Post by Jeffrey Walton
samples/le-proxy.c has a `use_wrapper` flag. Its used in, for example,
`accept_cb` (parts shown below). I don't quite understand its purpose.
There's also a `use_ssl` and that's tied to `ssl_ctx` (and the source
code mkes some decisions around `ssl_ctx`, which makes sense to me).
What is the purpose of `use_wrapper`?
There are two implementations of the OpenSSL bufferevent code. One
works by having OpenSSL do all the reads and writes to a socket
directly. The other works by wrapping around a lower-level
bufferevent.

For more information, see
http://www.wangafu.net/~nickm/libevent-book/Ref6a_advanced_bufferevents.html
.

Generally, you'll probably get better performance from the direct
implementation, unless you've got something unusual going on.

peace,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Loading...