]> granicus.if.org Git - libevent/commitdiff
Handle rate-limiting for reading on OpenSSL bufferevents correctly.
authorNick Mathewson <nickm@torproject.org>
Tue, 12 Oct 2010 16:59:13 +0000 (12:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 12 Oct 2010 16:59:46 +0000 (12:59 -0400)
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

index 1c59b7c5d7990044ca64dc6c6bbbdc97df79df1c..2477f5793856619cd536a6b9c5b0a9ec3f4e3b4d 100644 (file)
@@ -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;