From 819b1715723f1ab8bdf6f3d21d6eac859cf8950e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 12 Oct 2010 12:59:13 -0400 Subject: [PATCH] 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. --- bufferevent_openssl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- 2.50.0