From 4f16b4a00085d6214c1a6f6db5fbffb33f657abc Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 14 Sep 2009 11:40:36 +0100
Subject: [PATCH] ConfdAsyncUDPServer: handle signals at read time

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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/daemons/ganeti-confd b/daemons/ganeti-confd
index 8cf896a0c..b1696d658 100755
--- a/daemons/ganeti-confd
+++ b/daemons/ganeti-confd
@@ -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:
-- 
GitLab