interrupted system call" exceptions
Message-ID: <59142f5e.NgdgGV46TgmMDSZw%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: cea5a497e3855f9237223310df3badd37e22f0c3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cea5a497e3855f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 11 11:29:02 2017 +0200
4675 FIX Improved handling of rare but possible EINTR "interrupted system call"
exceptions
Change-Id: I3b6bab0474c6c30beb6077ad9385954f6fa0dcdb
---
.werks/4675 | 11 +++++++++++
bin/mkeventd | 32 +++++++++++++++++++++++++++-----
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/.werks/4675 b/.werks/4675
new file mode 100644
index 0000000..ee59238
--- /dev/null
+++ b/.werks/4675
@@ -0,0 +1,11 @@
+Title: Improved handling of rare but possible EINTR "interrupted system call"
exceptions
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1494494906
+
+
diff --git a/bin/mkeventd b/bin/mkeventd
index 9f88b36..a8461bf 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -32,6 +32,7 @@
# which fields are mandatory for the events.
import ast
+import errno
import socket, os, time, sys, getopt, signal, thread, pprint, re, \
select, subprocess, stat, string
import traceback
@@ -271,7 +272,13 @@ def open_logfile():
def drain_pipe(pipe):
while True:
- readable = select.select([ pipe ], [], [], 0.1)[0]
+ try:
+ readable = select.select([ pipe ], [], [], 10)[0]
+ except select.error, e:
+ if e[0] == errno.EINTR:
+ continue
+ raise
+
data = None
if pipe in readable:
try:
@@ -286,11 +293,15 @@ def drain_pipe(pipe):
def log(text):
if type(text) == unicode:
text = text.encode("utf-8")
+
+ msg = '[%.6f] %s\n' % (time.time(), text)
+
try:
- g_logfile.write('[%.6f] %s\n' % (time.time(), text))
+ g_logfile.write(msg)
g_logfile.flush()
except:
- sys.stderr.write("%s\n" % text)
+ sys.stderr.write(msg)
+ sys.stderr.flush()
def is_verbose():
@@ -1543,7 +1554,12 @@ class EventServer:
client_sockets = {}
select_timeout = 1
while True:
- readable = select.select(listen_list + client_sockets.keys(), [], [],
select_timeout)[0]
+ try:
+ readable = select.select(listen_list + client_sockets.keys(), [], [],
10)[0]
+ except select.error, e:
+ if e[0] == errno.EINTR:
+ continue
+ raise
data = None
# Accept new connection on event unix socket
@@ -2968,7 +2984,13 @@ class StatusServer:
if self._tcp_socket:
listen_list.append(self._tcp_socket)
- readable = select.select(listen_list, [], [], 0.2)[0]
+ try:
+ readable = select.select(listen_list, [], [], 10)[0]
+ except select.error, e:
+ if e[0] == errno.EINTR:
+ continue
+ raise
+
for s in readable:
client_socket, addr_info = s.accept()
client_socket.settimeout(3)