diff --git a/src/redis.c b/src/redis.c index c2a858fd..30816825 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2359,7 +2359,8 @@ sds genRedisInfoString(char *section) { /* Server */ if (allsections || defsections || !strcasecmp(section,"server")) { - struct utsname name; + static int call_uname = 1; + static struct utsname name; char *mode; if (server.cluster_enabled) mode = "cluster"; @@ -2367,7 +2368,13 @@ sds genRedisInfoString(char *section) { else mode = "standalone"; if (sections++) info = sdscat(info,"\r\n"); - uname(&name); + + if (call_uname) { + /* Uname can be slow and is always the same output. Cache it. */ + uname(&name); + call_uname = 0; + } + info = sdscatprintf(info, "# Server\r\n" "redis_version:%s\r\n"