ws_opcode_t oc;
if ( !wstp->ws_initialized ) {
- ws_init(ws, self->tp_socket, 65336, wstp->ws_secure ? wspri->ssl_ctx : NULL);
+ if (ws_init(ws, self->tp_socket, 65336, wstp->ws_secure ? wspri->ssl_ctx : NULL) == -2) {
+ return 2;
+ }
wstp->ws_initialized = 1;
self->tp_pre_framed = 1;
return 1;
N = ws_read_frame(ws, &oc, &data);
+ if (N == -2) {
+ return 2;
+ }
+
if (N == -1000) {
if (self->tp_msg)
msg_recv_commit(self->tp_msg, 0, 1);
ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes)
{
ssize_t r;
+ int x = 0;
if (wsh->ssl) {
do {
r = SSL_read(wsh->ssl, data, bytes);
- } while (r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_READ);
+ if (x++) {usleep(10000);
+ } while (r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_READ && x < 100);
return r;
}
do {
r = recv(wsh->sock, data, bytes, 0);
- } while (r == -1 && (errno == EAGAIN || errno == EINTR));
+ if (x++) {usleep(10000);
+ } while (r == -1 && (errno == EAGAIN || errno == EINTR) && x < 100);
if (r<0) {
//printf("READ FAIL: %s\n", strerror(errno));