From: Nick Mathewson Date: Tue, 12 Oct 2010 16:59:13 +0000 (-0400) Subject: Handle rate-limiting for reading on OpenSSL bufferevents correctly. X-Git-Tag: release-2.0.8-rc~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=819b1715723f1ab8bdf6f3d21d6eac859cf8950e;p=libevent Handle rate-limiting for reading on OpenSSL bufferevents correctly. We were looking at the number of bytes read on the wbio, not in the rbio. But these are usually different BIOs, and the reading is supposed to happen on the rbio. --- diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c index 1c59b7c5..2477f579 100644 --- a/bufferevent_openssl.c +++ b/bufferevent_openssl.c @@ -540,14 +540,14 @@ init_bio_counts(struct bufferevent_openssl *bev_ssl) bev_ssl->counts.n_written = BIO_number_written(SSL_get_wbio(bev_ssl->ssl)); bev_ssl->counts.n_read = - BIO_number_read(SSL_get_wbio(bev_ssl->ssl)); + BIO_number_read(SSL_get_rbio(bev_ssl->ssl)); } static inline void decrement_buckets(struct bufferevent_openssl *bev_ssl) { unsigned long num_w = BIO_number_written(SSL_get_wbio(bev_ssl->ssl)); - unsigned long num_r = BIO_number_read(SSL_get_wbio(bev_ssl->ssl)); + unsigned long num_r = BIO_number_read(SSL_get_rbio(bev_ssl->ssl)); /* These next two subtractions can wrap around. That's okay. */ unsigned long w = num_w - bev_ssl->counts.n_written; unsigned long r = num_r - bev_ssl->counts.n_read;