Allow users to set allow_dirty_shutdown

This commit is contained in:
Catalin Patulea 2011-11-21 19:57:19 -05:00 committed by Nick Mathewson
parent f7eb69ace4
commit 099d27df2b
2 changed files with 38 additions and 1 deletions

View File

@ -313,7 +313,7 @@ struct bufferevent_openssl {
unsigned read_blocked_on_write : 1;
/* When we next get data, we should say "write" instead of "read". */
unsigned write_blocked_on_read : 1;
/* XXX */
/* Treat TCP close before SSL close on SSL >= v3 as clean EOF. */
unsigned allow_dirty_shutdown : 1;
/* XXXX */
unsigned fd_is_set : 1;
@ -1389,6 +1389,27 @@ bufferevent_openssl_socket_new(struct event_base *base,
base, NULL, fd, ssl, state, options);
}
int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev)
{
int allow_dirty_shutdown = 0;
struct bufferevent_openssl *bev_ssl;
BEV_LOCK(bev);
bev_ssl = upcast(bev);
allow_dirty_shutdown = bev_ssl->allow_dirty_shutdown;
BEV_UNLOCK(bev);
return allow_dirty_shutdown;
}
void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev,
int allow_dirty_shutdown)
{
struct bufferevent_openssl *bev_ssl;
BEV_LOCK(bev);
bev_ssl = upcast(bev);
bev_ssl->allow_dirty_shutdown = allow_dirty_shutdown;
BEV_UNLOCK(bev);
}
unsigned long
bufferevent_get_openssl_error(struct bufferevent *bev)
{

View File

@ -88,6 +88,22 @@ bufferevent_openssl_socket_new(struct event_base *base,
enum bufferevent_ssl_state state,
int options);
/** Control whether to report dirty SSL shutdowns.
If the peer closes the TCP connection before closing the SSL channel, the
protocol is SSL >= v3, and allow_dirty_shutdown=0 (default), you will receive
BEV_EVENT_ERROR.
If instead allow_dirty_shutdown=1, you will receive BEV_EVENT_EOF.
On the other hand, if the protocol is < SSLv3, you will always receive
BEV_EVENT_EOF.
*/
int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev);
void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev,
int allow_dirty_shutdown);
/** Return the underlying openssl SSL * object for an SSL bufferevent. */
struct ssl_st *
bufferevent_openssl_get_ssl(struct bufferevent *bufev);