Skip to content

Commit

Permalink
ndb_redis: use the core macros for ending string value with '\0' and …
Browse files Browse the repository at this point in the history
…to restore
  • Loading branch information
miconda committed Apr 27, 2020
1 parent d6e24bd commit 4d758d5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/modules/ndb_redis/redis_client.c
Expand Up @@ -542,9 +542,7 @@ int redisc_append_cmd(str *srv, str *res, str *cmd, ...)
LM_ERR("no redis reply id found: %.*s\n", res->len, res->s);
goto error_cmd;
}

c = cmd->s[cmd->len];
cmd->s[cmd->len] = '\0';
STR_VTOZ(cmd->s[cmd->len], c);
rsrv->piped.commands[rsrv->piped.pending_commands].len = redisvFormatCommand(
&rsrv->piped.commands[rsrv->piped.pending_commands].s,
cmd->s,
Expand All @@ -557,7 +555,7 @@ int redisc_append_cmd(str *srv, str *res, str *cmd, ...)
rsrv->piped.replies[rsrv->piped.pending_commands]=rpl;
rsrv->piped.pending_commands++;

cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
va_end(ap);
return 0;

Expand Down Expand Up @@ -883,8 +881,7 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
goto error;
}

c = cmd->s[cmd->len];
cmd->s[cmd->len] = '\0';
STR_VTOZ(cmd->s[cmd->len], c);

rsrv = redisc_get_server(srv);
if(rsrv==NULL)
Expand Down Expand Up @@ -949,7 +946,7 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
redis_count_err_and_disable(rsrv);
LM_ERR("unable to reconnect to redis server: %.*s\n",
srv->len, srv->s);
cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
goto error_exec;
}
}
Expand Down Expand Up @@ -983,12 +980,12 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
} else {
LM_ERR("unable to reconnect to redis server: %.*s\n",
srv->len, srv->s);
cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
goto error_exec;
}
}
}
cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
rsrv->disable.consecutive_errors = 0;
va_end(ap);
va_end(ap2);
Expand All @@ -1000,12 +997,12 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
return 0;

error_exec:
cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
ret = -1;
goto error;

srv_disabled:
cmd->s[cmd->len] = c;
STR_ZTOV(cmd->s[cmd->len], c);
ret = -2;
goto error;

Expand Down

0 comments on commit 4d758d5

Please sign in to comment.