summaryrefslogtreecommitdiff
path: root/one.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2015-11-13 12:14:28 -0800
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2015-11-13 12:14:28 -0800
commit0d9f33dc4f14b7339d1893e79772a8e49b4821eb (patch)
treee7b3e1ee8ec92d57ce71482c64738f4211e5d9ff /one.cpp
parent90f9415107fded22346bfa94f98afa73c6c2811e (diff)
downloadinfinitytier-0d9f33dc4f14b7339d1893e79772a8e49b4821eb.tar.gz
infinitytier-0d9f33dc4f14b7339d1893e79772a8e49b4821eb.zip
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.
Diffstat (limited to 'one.cpp')
-rw-r--r--one.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/one.cpp b/one.cpp
index c8661fda..11bcc11e 100644
--- a/one.cpp
+++ b/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;