Browse Source

bit of cleanup
also make msgq recover from a crashing module


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac296@2654 e5f2f494-b856-4b98-b285-d166d9295462

Jelte Jansen 14 years ago
parent
commit
f8196cfb1a
2 changed files with 8 additions and 6 deletions
  1. 4 1
      src/bin/msgq/msgq.py.in
  2. 4 5
      src/lib/cc/session.cc

+ 4 - 1
src/bin/msgq/msgq.py.in

@@ -212,7 +212,10 @@ class MsgQ:
            EOF."""
         received = b''
         while len(received) < length:
-            data = sock.recv(length - len(received))
+            try:
+                data = sock.recv(length - len(received))
+            except socket.error:
+                raise MsgQReceiveError(socket.error)
             if len(data) == 0:
                 raise MsgQReceiveError("EOF")
             received += data

+ 4 - 5
src/lib/cc/session.cc

@@ -86,7 +86,7 @@ private:
     // Sets the boolean pointed to by result to true, unless
     // the given error code is operation_aborted
     // Used as a callback for emulating sync reads with async calls
-    void setResult(bool* result, asio::error_code* result_code, asio::error_code b);
+    void setResult(bool* result, asio::error_code* result_code, const asio::error_code& b);
 
 private:
     io_service& io_service_;
@@ -144,12 +144,11 @@ SessionImpl::readDataLength() {
 }
 
 void
-SessionImpl::setResult(bool* result, asio::error_code* result_code, const asio::error_code b) {
-    *result_code = b;
-
+SessionImpl::setResult(bool* result, asio::error_code* result_code, const asio::error_code& b) {
     // if the 'error' is operation_aborted (i.e. a call to cancel()),
     // we do not consider the read or the wait 'done'.
     if (b != asio::error::operation_aborted) {
+        *result_code = b;
         *result = true;
     }
 }
@@ -476,7 +475,7 @@ Session::setTimeout(size_t milliseconds) {
 
 size_t
 Session::getTimeout() {
-    return impl_->getTimeout();
+    return (impl_->getTimeout());
 }
 }
 }