Skip to content

Commit

Permalink
proto_ws: send error message before closing the connection
Browse files Browse the repository at this point in the history
Spotted by Rik Broers
  • Loading branch information
razvancrainea committed Apr 10, 2015
1 parent e252740 commit 44fa562
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/proto_ws/proto_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,16 @@ static void ws_conn_clean(struct tcp_connection* c)
if (!d)
return;

switch (d->code) {
case WS_ERR_NOSEND:
break;
case WS_ERR_NONE:
WS_CODE(c) = WS_ERR_NORMAL;
default:
ws_close(c);
break;
if (c->state == S_CONN_OK) {
switch (d->code) {
case WS_ERR_NOSEND:
break;
case WS_ERR_NONE:
WS_CODE(c) = WS_ERR_NORMAL;
default:
ws_close(c);
break;
}
}

shm_free(d);
Expand Down
4 changes: 4 additions & 0 deletions modules/proto_ws/ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ int ws_process(struct tcp_connection *con)
return size;
error:
WS_CODE(con) = ret_code;
if (WS_CODE(con) != WS_ERR_NONE) {
ws_send_close(con);
WS_CODE(con) = WS_ERR_NOSEND;
}
return -1;
}

Expand Down

0 comments on commit 44fa562

Please sign in to comment.