mirror of
https://github.com/joyieldInc/predixy.git
synced 2025-12-24 22:46:41 +08:00
1.fix issue14, don't add invalid sentinel address
2.add default compile option -g 3.fix command config get BufSize output 4.ignore online status for ClusterServerPool server
This commit is contained in:
parent
996e02fd4d
commit
3207be46ef
@ -148,7 +148,6 @@ void ClusterServerPool::handleResponse(Handler* h, ConnectConnection* s, Request
|
|||||||
p.master().data(),
|
p.master().data(),
|
||||||
serv->dcName().data());
|
serv->dcName().data());
|
||||||
} else {
|
} else {
|
||||||
serv->setOnline(true);
|
|
||||||
serv->setUpdating(false);
|
serv->setUpdating(false);
|
||||||
}
|
}
|
||||||
serv->setRole(p.role());
|
serv->setRole(p.role());
|
||||||
@ -192,12 +191,7 @@ void ClusterServerPool::handleResponse(Handler* h, ConnectConnection* s, Request
|
|||||||
}
|
}
|
||||||
for (auto serv : mServPool) {
|
for (auto serv : mServPool) {
|
||||||
if (serv->updating()) {
|
if (serv->updating()) {
|
||||||
serv->setOnline(false);
|
|
||||||
serv->setUpdating(false);
|
serv->setUpdating(false);
|
||||||
if (ServerGroup* g = serv->group()) {
|
|
||||||
g->remove(serv);
|
|
||||||
serv->setGroup(nullptr);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (serv->role() == Server::Master) {
|
if (serv->role() == Server::Master) {
|
||||||
|
|||||||
@ -1200,7 +1200,7 @@ void Handler::configGetRequest(Request* req)
|
|||||||
Append("Name", "%s", conf->name());
|
Append("Name", "%s", conf->name());
|
||||||
Append("Bind", "%s", conf->bind());
|
Append("Bind", "%s", conf->bind());
|
||||||
Append("WorkerThreads", "%d", conf->workerThreads());
|
Append("WorkerThreads", "%d", conf->workerThreads());
|
||||||
Append("BufSize", "%d", Buffer::getSize());
|
Append("BufSize", "%d", Buffer::getSize() + sizeof(Buffer));
|
||||||
Append("LocalDC", "%s", conf->localDC().c_str());
|
Append("LocalDC", "%s", conf->localDC().c_str());
|
||||||
Append("MaxMemory", "%ld", AllocBase::getMaxMemory());
|
Append("MaxMemory", "%ld", AllocBase::getMaxMemory());
|
||||||
Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000);
|
Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
CXX ?= g++
|
CXX ?= g++
|
||||||
LVL ?= -O3
|
LVL ?= -g -O3
|
||||||
Opts += $(LVL)
|
Opts += $(LVL)
|
||||||
|
|
||||||
ifeq ($(MT), false)
|
ifeq ($(MT), false)
|
||||||
|
|||||||
@ -275,6 +275,18 @@ AddrParser::Status AddrParser::parse(SString<Const::MaxAddrLen>& addr)
|
|||||||
return mState != Invalid ? Done : Error;
|
return mState != Invalid ? Done : Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool hasValidPort(const String& addr)
|
||||||
|
{
|
||||||
|
const char* p = addr.data() + addr.length();
|
||||||
|
for (int i = 0; i < addr.length(); ++i) {
|
||||||
|
if (*(--p) == ':') {
|
||||||
|
int port = atoi(p + 1);
|
||||||
|
return port > 0 && port < 65536;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SentinelServerPool::handleSentinels(Handler* h, ConnectConnection* s, Request* req, Response* res)
|
void SentinelServerPool::handleSentinels(Handler* h, ConnectConnection* s, Request* req, Response* res)
|
||||||
{
|
{
|
||||||
if (!res || !res->isArray()) {
|
if (!res || !res->isArray()) {
|
||||||
@ -286,6 +298,11 @@ void SentinelServerPool::handleSentinels(Handler* h, ConnectConnection* s, Reque
|
|||||||
auto st = parser.parse(addr);
|
auto st = parser.parse(addr);
|
||||||
if (st == AddrParser::Ok) {
|
if (st == AddrParser::Ok) {
|
||||||
logDebug("sentinel server pool parse sentinel %s", addr.data());
|
logDebug("sentinel server pool parse sentinel %s", addr.data());
|
||||||
|
if (!hasValidPort(addr)) {
|
||||||
|
logNotice("sentinel server pool parse sentienl %s invalid",
|
||||||
|
addr.data());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto it = mServs.find(addr);
|
auto it = mServs.find(addr);
|
||||||
Server* serv = it == mServs.end() ? nullptr : it->second;
|
Server* serv = it == mServs.end() ? nullptr : it->second;
|
||||||
if (!serv) {
|
if (!serv) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user