X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fserver.cc;h=d024d054ab02e4e6d1e284c7a601930f49f8238e;hb=dbc62573e1a6dc8cbcc97d0898e8615b0916d6ab;hp=a80a181239fb1f7d9ac42b486cac7370a7a5aaa8;hpb=bcc7e71dd0d2c7d875ddb3583fd5ab2585304642;p=awesomized%2Flibmemcached diff --git a/libtest/server.cc b/libtest/server.cc index a80a1812..d024d054 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_; @@ -173,6 +173,22 @@ bool Server::wait_for_pidfile() const return wait.successful(); } +bool Server::init(const char *argv[]) +{ + if (argv) + { + for (const char **ptr= argv; *ptr ; ++ptr) + { + if (ptr) + { + add_option(*ptr); + } + } + } + + return build(); +} + bool Server::has_pid() const { return (_app.pid() > 1); @@ -189,13 +205,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 +218,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 +288,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 +304,6 @@ bool Server::start() break; } - Error << "ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " " << error(); - this_wait= retry * retry / 3 + 1; libtest::dream(this_wait, 0); } @@ -300,6 +311,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,13 +498,16 @@ 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); + } } }