Minor cleanup in confirming socket close.
[awesomized/libmemcached] / libtest / server.cc
index 02aeec70203bc195d20507406d855d6773c503cf..522120be3e3f6c79081a49687c3cab368d502866 100644 (file)
@@ -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);
@@ -295,7 +295,9 @@ bool Server::start()
 
   if (pinged == false)
   {
-    Error << "ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " run:" << _running << " " << error();
+#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))
@@ -480,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
   {