[or-cvs] r9105: Try to fix an assert failure in new write limiting code: mak (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Wed Dec 13 22:46:43 UTC 2006


Author: nickm
Date: 2006-12-13 17:46:42 -0500 (Wed, 13 Dec 2006)
New Revision: 9105

Modified:
   tor/trunk/
   tor/trunk/src/common/tortls.c
   tor/trunk/src/common/tortls.h
   tor/trunk/src/or/buffers.c
Log:
 r11566 at Kushana:  nickm | 2006-12-13 17:46:24 -0500
 Try to fix an assert failure in new write limiting code: make buffers.c aware of previous "forced" write sizes from tortls.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11566] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/src/common/tortls.c
===================================================================
--- tor/trunk/src/common/tortls.c	2006-12-13 22:42:52 UTC (rev 9104)
+++ tor/trunk/src/common/tortls.c	2006-12-13 22:46:42 UTC (rev 9105)
@@ -850,7 +850,14 @@
     return 0;
 #endif
   return SSL_pending(tls->ssl);
+}
 
+/** If <b>tls</b> requires that the next write be of a particular size,
+ * return that size.  Otherwise, return 0. */
+size_t
+tor_tls_get_forced_write_size(tor_tls_t *tls)
+{
+  return tls->wantwrite_n;
 }
 
 /** Return the number of bytes read across the underlying socket. */

Modified: tor/trunk/src/common/tortls.h
===================================================================
--- tor/trunk/src/common/tortls.h	2006-12-13 22:42:52 UTC (rev 9104)
+++ tor/trunk/src/common/tortls.h	2006-12-13 22:46:42 UTC (rev 9105)
@@ -41,6 +41,7 @@
 int tor_tls_handshake(tor_tls_t *tls);
 int tor_tls_shutdown(tor_tls_t *tls);
 int tor_tls_get_pending_bytes(tor_tls_t *tls);
+size_t tor_tls_get_forced_write_size(tor_tls_t *tls);
 
 unsigned long tor_tls_get_n_bytes_read(tor_tls_t *tls);
 unsigned long tor_tls_get_n_bytes_written(tor_tls_t *tls);

Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c	2006-12-13 22:42:52 UTC (rev 9104)
+++ tor/trunk/src/or/buffers.c	2006-12-13 22:46:42 UTC (rev 9105)
@@ -648,16 +648,21 @@
   return flushed;
 }
 
-/** Helper for flush_buf_tls(): try to write <b>sz</b> bytes from buffer
- * <b>buf</b> onto TLS object <b>tls</b>.  On success, deduct the bytes
- * written from *<b>buf_flushlen</b>.
- * Return the number of bytes written on success, -1 on failure.
+/** Helper for flush_buf_tls(): try to write <b>sz</b> bytes (or more if
+ * required by a previous write) from buffer <b>buf</b> onto TLS object
+ * <b>tls</b>.  On success, deduct the bytes written from
+ * *<b>buf_flushlen</b>.  Return the number of bytes written on success, -1 on
+ * failure.
  */
 static INLINE int
 flush_buf_tls_impl(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen)
 {
   int r;
+  size_t forced;
 
+  forced = tor_tls_get_forced_write_size(tls);
+  if (forced < sz)
+    sz = forced;
   r = tor_tls_write(tls, buf->cur, sz);
   if (r < 0) {
     return r;



More information about the tor-commits mailing list