X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fserver.cc;h=61f8e9835cb29f9e48c6e613a8b8609a6c2d97ab;hb=d0a594f9c54ba0f9fe52fd92f261e48294fdc6e2;hp=726a01ba61f015637ae3d0f082892f0348491db5;hpb=a833bac7bfb7b59bb95e84cc8989d0edae6a6136;p=m6w6%2Flibmemcached diff --git a/libtest/server.cc b/libtest/server.cc index 726a01ba..61f8e983 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -99,7 +99,8 @@ Server::Server(const std::string& host_arg, const in_port_t port_arg, _is_socket(is_socket_arg), _port(port_arg), _hostname(host_arg), - _app(executable, _is_libtool) + _app(executable, _is_libtool), + out_of_ban_killed_(false) { } @@ -164,7 +165,9 @@ bool Server::start() // If we find that we already have a pid then kill it. if (has_pid() == true) { +#if 0 fatal_message("has_pid() failed, programer error"); +#endif } // This needs more work. @@ -190,6 +193,7 @@ bool Server::start() return false; } + libtest::release_port(_port); Application::error_t ret; if (Application::SUCCESS != (ret= _app.run())) { @@ -261,29 +265,38 @@ bool Server::start() _app.slurp(); if (kill_file(pid_file()) == false) { - throw libtest::fatal(LIBYATL_DEFAULT_PARAM, - "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %s stderr:%s", - this_wait, - pid_file().c_str(), - _app.stderr_c_str()); - } + libtest::fatal err(LIBYATL_DEFAULT_PARAM, + "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s", + this_wait, + int(_running.size()), _running.c_str(), + int(_app.stderr_result_length()), _app.stderr_c_str()); - throw libtest::fatal(LIBYATL_DEFAULT_PARAM, - "Failed native ping(), pid: %d is alive: %s waited: %u server started, having pid_file. exec: %s stderr:%s", + stream::cerr(err.file(), err.line(), err.func()) << err.what(); + } + else + { + libtest::fatal err(LIBYATL_DEFAULT_PARAM, + "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s", int(_app.pid()), _app.check() ? "true" : "false", - this_wait, _running.c_str(), - _app.stderr_c_str()); + this_wait, + int(_running.size()), _running.c_str(), + int(_app.stderr_result_length()), _app.stderr_c_str()); + + stream::cerr(err.file(), err.line(), err.func()) << err.what(); + } } else { - throw libtest::fatal(LIBYATL_DEFAULT_PARAM, - "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %s stderr:%s", - int(_app.pid()), - _app.check() ? "true" : "false", - this_wait, - _running.c_str(), - _app.stderr_c_str()); + libtest::fatal err(LIBYATL_DEFAULT_PARAM, + "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s", + int(_app.pid()), + _app.check() ? "true" : "false", + this_wait, + int(_running.size()), _running.c_str(), + int(_app.stderr_result_length()), _app.stderr_c_str()); + + stream::cerr(err.file(), err.line(), err.func()) << err.what(); } _running.clear(); return false; @@ -426,7 +439,7 @@ bool Server::args(Application& app) port_option(app, _port); } - for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++) + for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter) { if ((*iter).second.empty() == false) {