Skip to content

Commit

Permalink
Minor clean up + update documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Karthik Subbarao <karthikrs2021@gmail.com>
  • Loading branch information
KarthikSubbarao committed May 15, 2024
1 parent 802570b commit daae0d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
24 changes: 11 additions & 13 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,25 +513,23 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
if (!(flags & ERR_REPLY_FLAG_NO_STATS_UPDATE)) {
/* Increment the global error counter */
server.stat_total_error_replies++;
/* Increment the error stats */
/* After the errors RAX reaches this limit, instead of tracking
* custom LUA errors, we track the error under `error_LUA` */
if (flags & ERR_REPLY_FLAG_LUA && raxSize(server.errors) >= ERROR_STATS_LUA_LIMIT) {
incrementErrorCount("LUA_ERRORSTATS_DISABLED", 23);
/* If the string already starts with "-..." then the error prefix
* is provided by the caller ( we limit the search to 32 chars). Otherwise we use "-ERR". */
} else if (s[0] != '-') {
incrementErrorCount("ERR", 3);
} else {
/* Increment the error stats
* If the string already starts with "-..." then the error prefix
* is provided by the caller ( we limit the search to 32 chars). Otherwise we use "-ERR". */
if (s[0] != '-') {
incrementErrorCount("ERR", 3);
char *spaceloc = memchr(s, ' ', len < 32 ? len : 32);
if (spaceloc) {
const size_t errEndPos = (size_t)(spaceloc - s);
incrementErrorCount(s+1, errEndPos-1);
} else {
char *spaceloc = memchr(s, ' ', len < 32 ? len : 32);
if (spaceloc) {
const size_t errEndPos = (size_t)(spaceloc - s);
incrementErrorCount(s+1, errEndPos-1);
} else {
/* Fallback to ERR if we can't retrieve the error prefix */
incrementErrorCount("ERR", 3);
}
/* Fallback to ERR if we can't retrieve the error prefix */
incrementErrorCount("ERR", 3);
}
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2569,7 +2569,8 @@ void serverSetCpuAffinity(const char *cpulist);
/* afterErrorReply flags */
#define ERR_REPLY_FLAG_NO_STATS_UPDATE (1ULL<<0) /* Indicating that we should not update
error stats after sending error reply */
#define ERR_REPLY_FLAG_LUA (1ULL<<1) /* Indicating that we are coming in from ScriptCall */
#define ERR_REPLY_FLAG_LUA (1ULL<<1) /* Indicating that the error message is from LUA replying
to a client */

/* networking.c -- Networking and Client related operations */
client *createClient(connection *conn);
Expand Down

0 comments on commit daae0d8

Please sign in to comment.