mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-8761
This commit is contained in:
parent
1a70b70d79
commit
5c43a17a04
@ -1 +1 @@
|
|||||||
Tue Aug 16 13:39:03 CDT 2016
|
Mon Sep 12 11:23:22 CDT 2016
|
||||||
|
@ -352,14 +352,16 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
|||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
err = SSL_get_error(wsh->ssl, r);
|
err = SSL_get_error(wsh->ssl, r);
|
||||||
|
|
||||||
if (!block && err == SSL_ERROR_WANT_READ) {
|
if (err == SSL_ERROR_WANT_READ) {
|
||||||
|
if (!block) {
|
||||||
r = -2;
|
r = -2;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block) {
|
|
||||||
wsh->x++;
|
wsh->x++;
|
||||||
ms_sleep(10);
|
ms_sleep(10);
|
||||||
|
} else {
|
||||||
|
r = -1;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,12 +387,12 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
|||||||
}
|
}
|
||||||
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
|
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
|
||||||
|
|
||||||
|
end:
|
||||||
|
|
||||||
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
|
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
|
||||||
r = -1;
|
r = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
|
||||||
|
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
*((char *)data + r) = '\0';
|
*((char *)data + r) = '\0';
|
||||||
}
|
}
|
||||||
|
@ -352,14 +352,16 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
|||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
err = SSL_get_error(wsh->ssl, r);
|
err = SSL_get_error(wsh->ssl, r);
|
||||||
|
|
||||||
if (!block && err == SSL_ERROR_WANT_READ) {
|
if (err == SSL_ERROR_WANT_READ) {
|
||||||
|
if (!block) {
|
||||||
r = -2;
|
r = -2;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block) {
|
|
||||||
wsh->x++;
|
wsh->x++;
|
||||||
ms_sleep(10);
|
ms_sleep(10);
|
||||||
|
} else {
|
||||||
|
r = -1;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,12 +387,12 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
|||||||
}
|
}
|
||||||
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
|
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
|
||||||
|
|
||||||
|
end:
|
||||||
|
|
||||||
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
|
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
|
||||||
r = -1;
|
r = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
|
||||||
|
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
*((char *)data + r) = '\0';
|
*((char *)data + r) = '\0';
|
||||||
}
|
}
|
||||||
@ -500,7 +502,7 @@ static int restore_socket(ws_socket_t sock)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int establish_logical_layer(wsh_t *wsh)
|
int establish_logical_layer(wsh_t *wsh)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!wsh->sanity) {
|
if (!wsh->sanity) {
|
||||||
@ -929,38 +931,6 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t ws_feed_buf(wsh_t *wsh, void *data, size_t bytes)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (bytes + wsh->wdatalen > wsh->buflen) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((unsigned char *)wsh->write_buffer + wsh->write_buffer_len, data, bytes);
|
|
||||||
|
|
||||||
wsh->write_buffer_len += bytes;
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ssize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc)
|
|
||||||
{
|
|
||||||
ssize_t r = 0;
|
|
||||||
|
|
||||||
if (!wsh->wdatalen) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = ws_write_frame(wsh, oc, wsh->write_buffer, wsh->write_buffer_len);
|
|
||||||
|
|
||||||
wsh->wdatalen = 0;
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
|
ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
|
||||||
{
|
{
|
||||||
uint8_t hdr[14] = { 0 };
|
uint8_t hdr[14] = { 0 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user