Acquire lock when manipulating rx in SSL recv path

PUBLISHED_FROM=a34cfa3ebc12daf75d7f24c8d3f3707dcc33d9a2
This commit is contained in:
Deomid Ryabkov 2017-09-14 14:00:41 +03:00 committed by Cesanta Bot
parent 62c896a872
commit 8065439f96

View File

@ -15465,6 +15465,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) {
}
size_t seg_len = (seg->len - cs->rx_offset);
DBG(("%u %u %u %u", len, cs->rx_chain->len, seg_len, cs->rx_chain->tot_len));
mgos_lock();
len = MIN(len, seg_len);
pbuf_copy_partial(seg, buf, len, cs->rx_offset);
cs->rx_offset += len;
@ -15476,6 +15477,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) {
pbuf_free(seg);
cs->rx_offset = 0;
}
mgos_unlock();
LOG(LL_DEBUG, ("%p <- %d", nc, (int) len));
return len;
}