[sr-dev] git:andrei/tcp_tls_changes: tls: fix partial write on write-wants-read queue flush

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Aug 16 01:23:11 CEST 2010


Module: sip-router
Branch: andrei/tcp_tls_changes
Commit: 4f2a8e0cf2878fc53953b48761858bdf9a397857
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4f2a8e0cf2878fc53953b48761858bdf9a397857

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon Aug 16 01:12:41 2010 +0200

tls: fix partial write on write-wants-read queue flush

When flushing the queue the SSL_write() should be retried until
the queue is empty or there is an error (SSL_WANT_READ or
SSL_WANT_WRITE), since it is possible to have partial writes
smaller then the block size (SSL_write() will write at most 1
record when partial writes are enabled and with the
ssl_max_send_fragment option it is possible to set/have record
sizes smaller then typical writes).

---

 modules/tls/sbufq.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules/tls/sbufq.h b/modules/tls/sbufq.h
index cd29ecb..d50a1a4 100644
--- a/modules/tls/sbufq.h
+++ b/modules/tls/sbufq.h
@@ -265,7 +265,8 @@ inline static int sbufq_flush(struct sbuffer_queue* q, int* flags,
 			}else{
 				q->offset+=n;
 				q->queued-=n;
-				break;
+				/* no break: if we are here n < block_size => partial write
+				   => the write should be retried */
 			}
 		}else{
 			if (unlikely(n<0))




More information about the sr-dev mailing list