ConfdAsyncUDPServer: handle signals at read time
authorGuido Trotter <ultrotter@google.com>
Mon, 14 Sep 2009 10:40:36 +0000 (11:40 +0100)
committerGuido Trotter <ultrotter@google.com>
Wed, 16 Sep 2009 12:55:54 +0000 (13:55 +0100)
Currently if a signal is delivered during an attempted read, an
exception is logged in the logfile. There is no need for this, so we
handle this case explicitely.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

daemons/ganeti-confd

index 8cf896a..b1696d6 100755 (executable)
@@ -33,6 +33,7 @@ import asyncore
 import socket
 import pyinotify
 import time
+import errno
 
 from optparse import OptionParser
 
@@ -77,7 +78,15 @@ class ConfdAsyncUDPServer(asyncore.dispatcher):
   # this method is overriding an asyncore.dispatcher method
   def handle_read(self):
     try:
-      payload_in, address = self.recvfrom(4096)
+      try:
+        payload_in, address = self.recvfrom(4096)
+      except socket.error, err:
+        if err.errno == errno.EINTR:
+          # we got a signal while trying to read. no need to do anything,
+          # handle_read will be called again if there is data on the socket.
+          return
+        else:
+          raise
       ip, port = address
       payload_out =  self.processor.ExecQuery(payload_in, ip, port)
       if payload_out is not None: