Rename self_cmd to reused_cmd

master
Jessie Murray 3 years ago
parent b65c05a985
commit d48353cec3
No known key found for this signature in database
GPG Key ID: E7E4D57EDDA744C5

@ -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);

@ -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 */
};

@ -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;
}

@ -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);
}

@ -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);
}
});

Loading…
Cancel
Save