From 37fcab64a27bc39ed99b2c9138892df7fa2c872c Mon Sep 17 00:00:00 2001 From: SLPotapenko Date: Tue, 21 Aug 2018 09:39:34 +0300 Subject: [PATCH] fixed recursion after 'Ping server, no response :Resource temporarily unavailable' --- src/uwsc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/uwsc.c b/src/uwsc.c index 302e9be..97be27f 100644 --- a/src/uwsc.c +++ b/src/uwsc.c @@ -47,6 +47,8 @@ static void uwsc_free(struct uwsc_client *cl) static inline void uwsc_error(struct uwsc_client *cl, int error) { + uwsc_log_err("uwsc_error: %i\n", error); + cl->us->eof = true; cl->error = error; @@ -72,9 +74,11 @@ static void dispach_message(struct uwsc_client *cl) uloop_timeout_set(&cl->ping_timer, cl->ping_interval * 1000); break; case WEBSOCKET_OP_CLOSE: + uwsc_log_err("dispach_message: WEBSOCKET_OP_CLOSE\n"); uwsc_error(cl, 0); break; default: + uwsc_log_err("dispach_message: default - %i\n", frame->opcode); break; } } @@ -425,14 +429,15 @@ static int uwsc_send(struct uwsc_client *cl, void *data, int len, enum websocket ustream_write(cl->us, data, len, false); free(head); - if (op == WEBSOCKET_OP_CLOSE) - uwsc_error(cl, 0); + //if (op == WEBSOCKET_OP_CLOSE) + // uwsc_error(cl, 0); return 0; } static inline void uwsc_ping(struct uwsc_client *cl) { + uwsc_log_info("Ping server\n"); cl->send(cl, NULL, 0, WEBSOCKET_OP_PING); } @@ -466,7 +471,8 @@ static void uwsc_ping_cb(struct uloop_timeout *timeout) if (cl->wait_pingresp) { uwsc_log_err("Ping server, no response\n"); - cl->send(cl, NULL, 0, WEBSOCKET_OP_CLOSE); + uwsc_error(cl, 0); + uwsc_log_err("Send WEBSOCKET_OP_CLOSE complete\n"); return; }