summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-11-12 07:42:58 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-11-12 07:42:58 +0000
commit25752ef1924a01deaa1287f296b3754e4b593e1d (patch)
tree43a634eb240b55d358595ff5b9c53479bebc757d
parentb0b535bf4c71c8b9c54ca6186a2bcd3b5f790fb5 (diff)
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
-rw-r--r--pjlib/src/pj/ssl_sock_symbian.cpp16
1 files changed, 5 insertions, 11 deletions
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);