diff --git a/src/client.c b/src/client.c index c991895..ed6f3f3 100644 --- a/src/client.c +++ b/src/client.c @@ -287,14 +287,14 @@ http_client_read(struct http_client *c) { /* broken link, free buffer and client object */ /* disconnect pub/sub or WS client if there is one. */ - if(c->self_cmd && c->self_cmd->ac) { - struct cmd *cmd = c->self_cmd; + if(c->reused_cmd && c->reused_cmd->ac) { + struct cmd *cmd = c->reused_cmd; /* disconnect from all channels */ - redisAsyncDisconnect(c->self_cmd->ac); - // c->self_cmd might be already cleared by an event handler in redisAsyncDisconnect + redisAsyncDisconnect(c->reused_cmd->ac); + // c->reused_cmd might be already cleared by an event handler in redisAsyncDisconnect cmd->ac = NULL; - c->self_cmd = NULL; + c->reused_cmd = NULL; /* delete command object */ cmd_free(cmd); diff --git a/src/client.h b/src/client.h index 32e4c74..c355bac 100644 --- a/src/client.h +++ b/src/client.h @@ -61,7 +61,7 @@ struct http_client { char *separator; /* list separator for raw lists */ char *filename; /* content-disposition */ - struct cmd *self_cmd; + struct cmd *reused_cmd; struct ws_client *ws; /* websocket client */ }; diff --git a/src/cmd.c b/src/cmd.c index f064518..6fcc528 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -229,7 +229,7 @@ cmd_run(struct worker *w, struct http_client *client, cmd->ac = (redisAsyncContext*)pool_connect(w->pool, cmd->database, 0); /* register with the client, used upon disconnection */ - client->self_cmd = cmd; + client->reused_cmd = cmd; cmd->pub_sub_client = client; } else if(cmd->database != w->s->cfg->database) { /* create a new connection to Redis for custom DBs */ @@ -281,7 +281,7 @@ cmd_run(struct worker *w, struct http_client *client, } /* failed to find a suitable connection to Redis. */ cmd_free(cmd); - client->self_cmd = NULL; + client->reused_cmd = NULL; return CMD_REDIS_UNAVAIL; } diff --git a/src/formats/common.c b/src/formats/common.c index 5304b09..1932143 100644 --- a/src/formats/common.c +++ b/src/formats/common.c @@ -52,7 +52,7 @@ format_send_error(struct cmd *cmd, short code, const char *msg) { if (!cmd->is_websocket) { /* don't free or detach persistent cmd */ if (cmd->pub_sub_client) { /* for pub/sub, remove command from client */ - cmd->pub_sub_client->self_cmd = NULL; + cmd->pub_sub_client->reused_cmd = NULL; } else { cmd_free(cmd); } diff --git a/tests/websocket.html b/tests/websocket.html index 276bf84..f63bc3b 100644 --- a/tests/websocket.html +++ b/tests/websocket.html @@ -161,7 +161,6 @@ class Client { }; this.ws.onclose = event => { - console.log('ON CLOSE') $(`${this.type}-btn-connect`).innerText = 'Connect'; this.setConnectedState(false); this.subscribed = false; @@ -200,6 +199,7 @@ class Client { this.subscribed = true; this.setConnectedState(true); } catch (e) { + console.log('Error sending: ', serialized, e); } });