2017-08-25 11:09:08

by Olaf Hering

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Olaf Hering <[email protected]>
---
tools/hv/hv_fcopy_daemon.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index c273dd34d144..574e6bf5865c 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -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);
}


2017-08-25 12:27:33

by Vitaly Kuznetsov

[permalink] [raw]
Subject: Re: [PATCH] tools: hv: handle EINTR in hv_fcopy_daemon

Olaf Hering <[email protected]> writes:

> If strace attaches to the daemon pread returns with EINTR, and the
> process exits. Catch this case and continue with the next iteration.
>
> Signed-off-by: Olaf Hering <[email protected]>
> ---
> tools/hv/hv_fcopy_daemon.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index c273dd34d144..574e6bf5865c 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -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?

--
Vitaly

2017-08-25 12:31:06

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] tools: hv: handle EINTR in hv_fcopy_daemon

On Fri, Aug 25, Vitaly Kuznetsov wrote:

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

If that works better, probably yes.

Olaf


Attachments:
(No filename) (161.00 B)
signature.asc (195.00 B)
Download all attachments

2017-09-05 18:16:46

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH] tools: hv: handle EINTR in hv_fcopy_daemon

Olaf,

Were you planning on sending a patch for this.

K. Y

> -----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
>
> On Fri, Aug 25, Vitaly Kuznetsov wrote:
>
> > Shall we request SA_RESTART with sigaction() in all three daemons instead?
>
> If that works better, probably yes.
>
> Olaf

2017-09-05 19:43:35

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] tools: hv: handle EINTR in hv_fcopy_daemon

On Tue, Sep 05, KY Srinivasan wrote:

> Were you planning on sending a patch for this.

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

Olaf


Attachments:
(No filename) (141.00 B)
signature.asc (195.00 B)
Download all attachments