tls: fix partial write on write-wants-read queue flush
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Sun, 15 Aug 2010 23:12:41 +0000 (01:12 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Sun, 15 Aug 2010 23:12:41 +0000 (01:12 +0200)
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

index cd29ecb..d50a1a4 100644 (file)
@@ -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))