Commit 4f16b4a0 authored by Guido Trotter's avatar Guido Trotter
Browse files

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: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 7a0156dc
...@@ -33,6 +33,7 @@ import asyncore ...@@ -33,6 +33,7 @@ import asyncore
import socket import socket
import pyinotify import pyinotify
import time import time
import errno
from optparse import OptionParser from optparse import OptionParser
...@@ -77,7 +78,15 @@ class ConfdAsyncUDPServer(asyncore.dispatcher): ...@@ -77,7 +78,15 @@ class ConfdAsyncUDPServer(asyncore.dispatcher):
# this method is overriding an asyncore.dispatcher method # this method is overriding an asyncore.dispatcher method
def handle_read(self): def handle_read(self):
try: 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 ip, port = address
payload_out = self.processor.ExecQuery(payload_in, ip, port) payload_out = self.processor.ExecQuery(payload_in, ip, port)
if payload_out is not None: if payload_out is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment