Fix: (1) Windows stack overflow due to buffer too large in peer deserialize, (2) clean up some other stuff seen during debugging and reduce the sizes of some buffers due to Windows small stack size, (3) remove a redundant try/catch.
This commit is contained in:
60
one.cpp
60
one.cpp
@@ -958,13 +958,15 @@ int main(int argc,char **argv)
|
||||
#endif // __UNIX_LIKE__
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2,2),&wsaData);
|
||||
{
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2,2),&wsaData);
|
||||
}
|
||||
|
||||
#ifdef ZT_WIN_RUN_IN_CONSOLE
|
||||
bool winRunFromCommandLine = true;
|
||||
#else
|
||||
bool winRunFromCommandLine = false;
|
||||
bool winRunFromCommandLine = true;
|
||||
#endif
|
||||
#endif // __WINDOWS__
|
||||
|
||||
@@ -1153,37 +1155,29 @@ int main(int argc,char **argv)
|
||||
|
||||
unsigned int returnValue = 0;
|
||||
|
||||
try {
|
||||
for(;;) {
|
||||
zt1Service = OneService::newInstance(homeDir.c_str(),port);
|
||||
switch(zt1Service->run()) {
|
||||
case OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done
|
||||
case OneService::ONE_NORMAL_TERMINATION:
|
||||
break;
|
||||
case OneService::ONE_UNRECOVERABLE_ERROR:
|
||||
fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str());
|
||||
returnValue = 1;
|
||||
break;
|
||||
case OneService::ONE_IDENTITY_COLLISION: {
|
||||
delete zt1Service;
|
||||
zt1Service = (OneService *)0;
|
||||
std::string oldid;
|
||||
OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
|
||||
if (oldid.length()) {
|
||||
OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
|
||||
OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
|
||||
OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
|
||||
}
|
||||
} continue; // restart!
|
||||
}
|
||||
break; // terminate loop -- normally we don't keep restarting
|
||||
for(;;) {
|
||||
zt1Service = OneService::newInstance(homeDir.c_str(),port);
|
||||
switch(zt1Service->run()) {
|
||||
case OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done
|
||||
case OneService::ONE_NORMAL_TERMINATION:
|
||||
break;
|
||||
case OneService::ONE_UNRECOVERABLE_ERROR:
|
||||
fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str());
|
||||
returnValue = 1;
|
||||
break;
|
||||
case OneService::ONE_IDENTITY_COLLISION: {
|
||||
delete zt1Service;
|
||||
zt1Service = (OneService *)0;
|
||||
std::string oldid;
|
||||
OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
|
||||
if (oldid.length()) {
|
||||
OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
|
||||
OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
|
||||
OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
|
||||
}
|
||||
} continue; // restart!
|
||||
}
|
||||
} catch (std::exception &exc) {
|
||||
fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],exc.what());
|
||||
returnValue = 1;
|
||||
} catch ( ... ) {
|
||||
fprintf(stderr,"%s: fatal error: unknown exception"ZT_EOL_S,argv[0]);
|
||||
returnValue = 1;
|
||||
break; // terminate loop -- normally we don't keep restarting
|
||||
}
|
||||
|
||||
delete zt1Service;
|
||||
|
||||
Reference in New Issue
Block a user