Browse Source

Fix shutdown operation

Brian Aker 13 years ago
parent
commit
42dd0cb3ac
3 changed files with 16 additions and 3 deletions
  1. 2 2
      bin/gearadmin.cc
  2. 12 1
      util/instance.cc
  3. 2 0
      util/operation.cc

+ 2 - 2
bin/gearadmin.cc

@@ -168,7 +168,7 @@ int main(int args, char *argv[])
 
   if (vm.count("shutdown"))
   {
-    instance.push(new util::Operation(util_literal_param("shutdown\r\n"), false));
+    instance.push(new util::Operation(util_literal_param("shutdown\r\n")));
   }
 
   if (vm.count("status"))
@@ -209,7 +209,7 @@ int main(int args, char *argv[])
 
   if (vm.count("getpid"))
   {
-    instance.push(new util::Operation(util_literal_param("getpid\r\n"), true));
+    instance.push(new util::Operation(util_literal_param("getpid\r\n")));
   }
 
   instance.run();

+ 12 - 1
util/instance.cc

@@ -220,13 +220,24 @@ bool Instance::run()
             switch(errno)
             {
             default:
-              std::cerr << "Error occured while reading data from " << _host.c_str() << std::endl;
+              _last_error.clear();
+              _last_error+= "Error occured while reading data from ";
+              _last_error+= _host;
               return false;
             }
           }
+          else if (read_length == 0)
+          {
+            _last_error.clear();
+            _last_error+= "Socket was shutdown while reading from ";
+            _last_error+= _host;
+
+            return false;
+          }
 
           operation->push(buffer, static_cast<size_t>(read_length));
           total_read+= static_cast<size_t>(read_length);
+
         } while (more_to_read());
       } // end has_response
 

+ 2 - 0
util/operation.cc

@@ -47,7 +47,9 @@ namespace util {
 bool Operation::response(std::string &arg)
 {
   if (_response.empty())
+  {
     return false;
+  }
 
   if (not memcmp("OK\r\n", &_response[0], 3))
   { }