X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fserver.cc;h=522120be3e3f6c79081a49687c3cab368d502866;hb=48e6e1b70b3b79f79334bdea8bfbbb76d377be07;hp=42c6b480d56b69122a7800aa43e18ad08e6bd09d;hpb=025203ede75bcf5508ab9e2e842352039ec45d40;p=awesomized%2Flibmemcached diff --git a/libtest/server.cc b/libtest/server.cc index 42c6b480..522120be 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -98,7 +98,7 @@ class Buffer { public: Buffer(char *b) : b_(b) {} - ~Buffer() { free(b_); } + ~Buffer() { if (b_) free(b_); } char* buf() { return b_; } private: char *b_; @@ -124,7 +124,7 @@ Server::Server(const std::string& host_arg, const in_port_t port_arg, Server::~Server() { - kill(); + murder(); } bool Server::check() @@ -148,7 +148,7 @@ bool Server::cycle() while (--limit and is_pid_valid(_app.pid())) { - if (kill()) + if (murder()) { Log << "Killed existing server," << *this; dream(0, 50000); @@ -189,13 +189,10 @@ bool Server::start() #endif } - // This needs more work. -#if 0 - if (gdb_is_caller()) + if (getenv("YATL_GDB_SERVER")) { - _app.use_gdb(); + _app.use_gdb(true); } -#endif if (port() == LIBTEST_FAIL_PORT) { @@ -205,11 +202,11 @@ bool Server::start() if (getenv("YATL_PTRCHECK_SERVER")) { - _app.use_ptrcheck(); + _app.use_ptrcheck(true); } else if (getenv("YATL_VALGRIND_SERVER")) { - _app.use_valgrind(); + _app.use_valgrind(true); } out_of_ban_killed(false); @@ -275,7 +272,7 @@ bool Server::start() uint32_t waited; uint32_t retry; - for (waited= 0, retry= 7; ; retry++, waited+= this_wait) + for (waited= 0, retry= 1; ; retry++, waited+= this_wait) { if (_app.check() == false) { @@ -291,8 +288,6 @@ bool Server::start() break; } - Error << "ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " run:" << _running << " " << error(); - this_wait= retry * retry / 3 + 1; libtest::dream(this_wait, 0); } @@ -300,6 +295,10 @@ bool Server::start() if (pinged == false) { +#if 0 + Error << "Failed to ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " run:" << _running << " " << error(); +#endif + // If we happen to have a pid file, lets try to kill it if ((pid_file().empty() == false) and (access(pid_file().c_str(), R_OK) == 0)) { @@ -483,20 +482,23 @@ bool Server::args(Application& app) for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter) { - if ((*iter).second.empty() == false) - { - app.add_option((*iter).first, (*iter).second); - } - else + if ((*iter).first.empty() == false) { - app.add_option((*iter).first); + if ((*iter).second.empty() == false) + { + app.add_option((*iter).first, (*iter).second); + } + else + { + app.add_option((*iter).first); + } } } return true; } -bool Server::kill() +bool Server::murder() { if (check_pid(_app.pid())) // If we kill it, reset {