fix crash because server without DC, but config defined DC, see #32

This commit is contained in:
fortrue 2018-04-29 19:34:32 +08:00
parent 28edb79c61
commit bbbe798629

View File

@ -162,6 +162,9 @@ Server* ServerGroup::getReadServer(Handler* h, DC* localDC) const
continue; continue;
} }
DC* dc = s->dc(); DC* dc = s->dc();
if (!dc) {
continue;
}
int dcrp = localDC->getReadPriority(dc); int dcrp = localDC->getReadPriority(dc);
if (dcrp <= 0) { if (dcrp <= 0) {
continue; continue;
@ -221,7 +224,7 @@ Server* ServerGroup::getReadServer(Handler* h, DC* localDC) const
dc = sdc[0]; dc = sdc[0];
found = true; found = true;
} }
if (!found) {//dc maybe nullptr even we found if (!found) {
return nullptr; return nullptr;
} }
Server* deadServs[Const::MaxServInGroup]; Server* deadServs[Const::MaxServInGroup];