From 45661645edc6e296c63fbdf96a6da0ede076078e Mon Sep 17 00:00:00 2001 From: fortrue Date: Tue, 26 Dec 2017 14:27:09 +0800 Subject: [PATCH] 1.add more information for command info and config get 2.fix log file symbol link error --- src/Handler.cpp | 8 +++++++- src/LogFileSink.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Handler.cpp b/src/Handler.cpp index 4ae42c6..5e8bd77 100644 --- a/src/Handler.cpp +++ b/src/Handler.cpp @@ -899,7 +899,8 @@ void Handler::infoRequest(Request* req, const String& key) #define Scope(all, empty, header) ((all || empty || key.equal(header, true)) ? \ (buf = buf->fappend("# %s\n", header)) : nullptr) - if (Scope(all, empty, "Proxy")) { + if (all || empty || key.equal("Proxy", true) || key.equal("Server", true)) { + buf = buf->fappend("# %s\n", "Proxy"); buf = buf->fappend("Version:%s\n", _PREDIXY_VERSION_); buf = buf->fappend("Name:%s\n", mProxy->conf()->name()); buf = buf->fappend("Bind:%s\n", mProxy->conf()->bind()); @@ -1196,6 +1197,11 @@ void Handler::configGetRequest(Request* req) } do { + Append("Name", "%s", conf->name()); + Append("Bind", "%s", conf->bind()); + Append("WorkerThreads", "%d", conf->workerThreads()); + Append("BufSize", "%d", Buffer::getSize()); + Append("LocalDC", "%s", conf->localDC().c_str()); Append("MaxMemory", "%ld", AllocBase::getMaxMemory()); Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000); Append("AllowMissLog", "%s", log->allowMissLog() ? "true" : "false"); diff --git a/src/LogFileSink.cpp b/src/LogFileSink.cpp index 00e25a2..8e5624c 100644 --- a/src/LogFileSink.cpp +++ b/src/LogFileSink.cpp @@ -118,7 +118,9 @@ bool LogFileSink::reopen(time_t t) } if (mFileSuffixFmt) { unlink(mFileName.c_str()); - if (symlink(mFilePath, mFileName.c_str()) == -1) { + const char* name = strrchr(mFilePath, '/'); + name = name ? name + 1 : mFilePath; + if (symlink(name, mFileName.c_str()) == -1) { fprintf(stderr, "create symbol link for %s fail", mFileName.c_str()); } } @@ -135,9 +137,9 @@ bool LogFileSink::setFile(const char* path, int rotateSecs, long rotateBytes) if (len > 4 && strcasecmp(path + len - 4, ".log") == 0) { len -= 4; } - if (len + FileSuffixReserveLen >= MaxPathLen) { - return false; - } + } + if (len + FileSuffixReserveLen >= MaxPathLen) { + return false; } mFileName = path; mFilePathLen = len;