]> git.proxmox.com Git - swtpm.git/commitdiff
swtpm: loop in case poll sets errno EINTR
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 30 Jan 2018 14:07:42 +0000 (09:07 -0500)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 30 Jan 2018 14:07:46 +0000 (09:07 -0500)
In case the poll() is interrupted by a signal handler and we
get EINTR, we loop again assuming that the signal handler will
send us a notification to end.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/swtpm/mainloop.c

index cc3c034b75f0292ed439d62bdb878c1e8b736246..dfa7e4034e13971e74a3c4fdfe92025a5d61246f 100644 (file)
@@ -94,6 +94,7 @@ int mainLoop(struct mainLoopParams *mlp,
     int                 ctrlclntfd;
     bool                readall;
     int                 sockfd;
+    int                 ready;
 
     /* poolfd[] indexes */
     enum {
@@ -156,7 +157,11 @@ int mainLoop(struct mainLoopParams *mlp,
             if (connection_fd.fd < 0)
                 pollfds[DATA_SERVER_FD].fd = sockfd;
 
-            if (poll(pollfds, 5, -1) < 0 ||
+            ready = poll(pollfds, 5, -1);
+            if (ready < 0 && errno == EINTR)
+                continue;
+
+            if (ready < 0 ||
                 (pollfds[NOTIFY_FD].revents & POLLIN) != 0) {
                 SWTPM_IO_Disconnect(&connection_fd);
                 break;