summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2019-09-26 11:58:52 +0200
committerGitHub <noreply@github.com>2019-09-26 11:58:52 +0200
commitc1ea6175c5353b37b15e418ddecb7cf87944ccb6 (patch)
treeef9b858b32575c81bbbbcb80a57060fcfc61bb6a
parent959fb5cf6879c5fb04e8fcf00efda4816e358d0d (diff)
parent52686f48664e8a01e556e6a7ee52013816514a26 (diff)
downloadredis-c1ea6175c5353b37b15e418ddecb7cf87944ccb6.tar.gz
Merge pull request #6024 from itamarhaber/info_modules
Adds a "Modules" section to `INFO`
-rw-r--r--src/module.c19
-rw-r--r--src/server.c7
-rw-r--r--src/server.h1
3 files changed, 27 insertions, 0 deletions
diff --git a/src/module.c b/src/module.c
index a9db0a3a5..71fdd6b74 100644
--- a/src/module.c
+++ b/src/module.c
@@ -5363,6 +5363,25 @@ void addReplyLoadedModules(client *c) {
dictReleaseIterator(di);
}
+/* Helper function for the INFO command: adds loaded modules as to info's
+ * output.
+ *
+ * After the call, the passed sds info string is no longer valid and all the
+ * references must be substituted with the new pointer returned by the call. */
+sds genModulesInfoString(sds info) {
+ dictIterator *di = dictGetIterator(modules);
+ dictEntry *de;
+
+ while ((de = dictNext(di)) != NULL) {
+ sds name = dictGetKey(de);
+ struct RedisModule *module = dictGetVal(de);
+
+ info = sdscatprintf(info, "module:name=%s,ver=%d\r\n", name, module->ver);
+ }
+ dictReleaseIterator(di);
+ return info;
+}
+
/* Redis MODULE command.
*
* MODULE LOAD <path> [args...] */
diff --git a/src/server.c b/src/server.c
index 51106abe0..9d70e5c1c 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4340,6 +4340,13 @@ sds genRedisInfoString(char *section) {
(long)c_ru.ru_utime.tv_sec, (long)c_ru.ru_utime.tv_usec);
}
+ /* Modules */
+ if (allsections || defsections || !strcasecmp(section,"modules")) {
+ if (sections++) info = sdscat(info,"\r\n");
+ info = sdscatprintf(info,"# Modules\r\n");
+ info = genModulesInfoString(info);
+ }
+
/* Command statistics */
if (allsections || !strcasecmp(section,"commandstats")) {
if (sections++) info = sdscat(info,"\r\n");
diff --git a/src/server.h b/src/server.h
index d0d0ece1c..7759081b0 100644
--- a/src/server.h
+++ b/src/server.h
@@ -2335,6 +2335,7 @@ void bugReportStart(void);
void serverLogObjectDebugInfo(const robj *o);
void sigsegvHandler(int sig, siginfo_t *info, void *secret);
sds genRedisInfoString(char *section);
+sds genModulesInfoString(sds info);
void enableWatchdog(int period);
void disableWatchdog(void);
void watchdogScheduleSignal(int period);