Skip to contentSkip to conversation

tools: hv: handle EINTR in hv_fcopy_daemon

PATCH In review Olaf Hering 3 participants 5 messages Aug 25, 2017 – Sep 5, 2017 Hyper-V/Azure core and drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: hv: handle EINTR in hv_fcopy_daemon

If strace attaches to the daemon pread returns with EINTR, and the process exits. Catch this case and continue with the next iteration.

---
 tools/hv/hv_fcopy_daemon.c | 2 ++
 1 file changed, 2 insertions(+)
tools/hv/hv_fcopy_daemon.c +2 -0
index c273dd34d144..574e6bf5865c 100644
@@ -201,6 +201,8 @@ int main(int argc, char *argv[])
 		ssize_t len;
 		len = pread(fcopy_fd, &buffer, sizeof(buffer), 0);
 		if (len < 0) {
+			if (errno == EINTR)
+				continue;
 			syslog(LOG_ERR, "pread failed: %s", strerror(errno));
 			exit(EXIT_FAILURE);
 		}
#1 lore raw
Quoted 13 lines · Olaf Hering

If strace attaches to the daemon pread returns with EINTR, and the process exits. Catch this case and continue with the next iteration.

---
 tools/hv/hv_fcopy_daemon.c | 2 ++
 1 file changed, 2 insertions(+)
tools/hv/hv_fcopy_daemon.c +0 -0
index c273dd34d144..574e6bf5865c 100644

tools/hv/hv_fcopy_daemon.c int main(int argc, char *argv[]) · line 208

Quoted 8 lines
tools/hv/hv_fcopy_daemon.c +2 -0
@@ -201,6 +201,8 @@ int main(int argc, char *argv[])
 		ssize_t len;
 		len = pread(fcopy_fd, &buffer, sizeof(buffer), 0);
 		if (len < 0) {
+			if (errno == EINTR)
+				continue;
 			syslog(LOG_ERR, "pread failed: %s", strerror(errno));
 			exit(EXIT_FAILURE);
 		}

Shall we request SA_RESTART with sigaction() in all three daemons instead?

Signature · 1 line
  Vitaly
#2 lore raw
Quoted 1 line · Vitaly Kuznetsov

Shall we request SA_RESTART with sigaction() in all three daemons instead?

If that works better, probably yes.

Olaf

#3 lore raw

Olaf,

Were you planning on sending a patch for this.

K. Y

Quoted 17 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, August 25, 2017 5:31 AM
To: Vitaly Kuznetsov <[email protected]>
Cc: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; open list:Hyper-V CORE AND DRIVERS <[email protected]>; open list <[email protected]>
Subject: Re: [PATCH] tools: hv: handle EINTR in hv_fcopy_daemon

Quoted 1 line · Vitaly Kuznetsov

Shall we request SA_RESTART with sigaction() in all three daemons instead?

If that works better, probably yes.

Olaf

#4 lore raw
Quoted 1 line · KY Srinivasan

Were you planning on sending a patch for this.

No, not yet. I dont know how SA_RESTART works.

Olaf