Skip to content

Commit

Permalink
fixed recursion after 'Ping server, no response :Resource temporarily…
Browse files Browse the repository at this point in the history
… unavailable'
  • Loading branch information
spot62 committed Aug 21, 2018
1 parent 513aaab commit 37fcab6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/uwsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 37fcab6

Please sign in to comment.