From 25752ef1924a01deaa1287f296b3754e4b593e1d Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 12 Nov 2010 07:42:58 +0000 Subject: Fix #1157: Fixed Symbian SSL socket to re-align the write (circular) buffer only when all pending write requests are completed, i.e: inside the write completion callback and when the buffer is empty. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3364 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/ssl_sock_symbian.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'pjlib/src/pj/ssl_sock_symbian.cpp') diff --git a/pjlib/src/pj/ssl_sock_symbian.cpp b/pjlib/src/pj/ssl_sock_symbian.cpp index 9237ef13..9027350a 100644 --- a/pjlib/src/pj/ssl_sock_symbian.cpp +++ b/pjlib/src/pj/ssl_sock_symbian.cpp @@ -1020,6 +1020,9 @@ static void send_cb(int err, void *key) st->len = 0; return; } + } else { + /* Buffer empty, reset the start position */ + st->start = st->buf; } } @@ -1058,25 +1061,16 @@ PJ_DEF(pj_status_t) pj_ssl_sock_send (pj_ssl_sock_t *ssock, * operations at any time. */ - pj_size_t avail_len = st->max_len - st->len; pj_size_t needed_len = *size + sizeof(write_data_t) - 1; /* Align needed_len to be multiplication of 4 */ needed_len = ((needed_len + 3) >> 2) << 2; - /* Block until there is buffer slot available! */ - while (needed_len >= avail_len) { + /* Block until there is buffer slot available and contiguous! */ + while (st->start + st->len + needed_len > st->buf + st->max_len) { pj_symbianos_poll(-1, -1); - avail_len = st->max_len - st->len; } - /* Ok, make sure the new data will not get wrapped */ - if (st->start + st->len + needed_len > st->buf + st->max_len) { - /* Align buffer left */ - pj_memmove(st->buf, st->start, st->len); - st->start = st->buf; - } - /* Push back the send data into the buffer */ write_data_t *wdata = (write_data_t*)(st->start + st->len); -- cgit v1.2.3