From: Steven Rostedt <rostedt@goodmis.org>
To: Michael Sartain <mikesart@fastmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/6] Handle EINTR signal interrupts for read, write, open calls
Date: Wed, 21 Jun 2017 09:26:23 -0400 [thread overview]
Message-ID: <20170621092623.5b85244e@gandalf.local.home> (raw)
In-Reply-To: <ecae4edb28992584605744a48e0803bd861724f1.1497486273.git.mikesart@fastmail.com>
On Wed, 14 Jun 2017 18:27:58 -0600
Michael Sartain <mikesart@fastmail.com> wrote:
> Read/write/open calls weren't handling EINTR in trace-input.c
>
> This patch uses the standard GNU C TEMP_FAILURE_RETRY macro to handle EINTR
> return values, and updates read/write calls in trace-msg.c to match.
I understand that GNU C gives the TEMP_FAILURE_RETRY() macro, but I
find it really ugly, and takes away from the flow of the code. Perhaps
we should just add our own static inline functions of the same name:
write_intr(), read_intr(), open_intr()
that does the same thing and use that instead. The inline functions
could even use the TEMP_FAILURE_RETRY(). I just don't want that ugly
name scattered in the .c code.
Thanks!
-- Steve
>
> Signed-off-by: Michael Sartain <mikesart@fastmail.com>
> ---
> trace-cmd-local.h | 2 +-
> trace-input.c | 8 ++++----
> trace-msg.c | 8 ++------
> 3 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/trace-cmd-local.h b/trace-cmd-local.h
> index 9412f9d..8595a8a 100644
> --- a/trace-cmd-local.h
> +++ b/trace-cmd-local.h
> @@ -31,7 +31,7 @@ static ssize_t __do_write(int fd, const void *data, size_t size)
> ssize_t w;
>
> do {
> - w = write(fd, data, size - tot);
> + w = TEMP_FAILURE_RETRY(write(fd, data, size - tot));
> tot += w;
>
> if (!w)
> diff --git a/trace-input.c b/trace-input.c
> index 89ddcf5..251d32b 100644
> --- a/trace-input.c
> +++ b/trace-input.c
> @@ -202,7 +202,7 @@ static ssize_t do_read(struct tracecmd_input *handle, void *data, size_t size)
> ssize_t r;
>
> do {
> - r = read(handle->fd, data, size - tot);
> + r = TEMP_FAILURE_RETRY(read(handle->fd, data, size - tot));
> tot += r;
>
> if (!r)
> @@ -774,7 +774,7 @@ static int read_page(struct tracecmd_input *handle, off64_t offset,
> off64_t ret;
>
> if (handle->use_pipe) {
> - ret = read(handle->cpu_data[cpu].pipe_fd, map, handle->page_size);
> + ret = TEMP_FAILURE_RETRY(read(handle->cpu_data[cpu].pipe_fd, map, handle->page_size));
> /* Set EAGAIN if the pipe is empty */
> if (ret < 0) {
> errno = EAGAIN;
> @@ -2645,7 +2645,7 @@ struct tracecmd_input *tracecmd_alloc(const char *file)
> {
> int fd;
>
> - fd = open(file, O_RDONLY);
> + fd = TEMP_FAILURE_RETRY(open(file, O_RDONLY));
> if (fd < 0)
> return NULL;
>
> @@ -2686,7 +2686,7 @@ struct tracecmd_input *tracecmd_open(const char *file)
> {
> int fd;
>
> - fd = open(file, O_RDONLY);
> + fd = TEMP_FAILURE_RETRY(open(file, O_RDONLY));
> if (fd < 0)
> return NULL;
>
> diff --git a/trace-msg.c b/trace-msg.c
> index 3991985..d358318 100644
> --- a/trace-msg.c
> +++ b/trace-msg.c
> @@ -291,10 +291,8 @@ static int msg_read(int fd, void *buf, u32 size, int *n)
> ssize_t r;
>
> while (size) {
> - r = read(fd, buf + *n, size);
> + r = TEMP_FAILURE_RETRY(read(fd, buf + *n, size));
> if (r < 0) {
> - if (errno == EINTR)
> - continue;
> return -errno;
> } else if (!r)
> return -ENOTCONN;
> @@ -662,10 +660,8 @@ int tracecmd_msg_collect_metadata(int ifd, int ofd)
> t = n;
> s = 0;
> do {
> - s = write(ofd, msg.data.meta.buf+s, t);
> + s = TEMP_FAILURE_RETRY(write(ofd, msg.data.meta.buf+s, t));
> if (s < 0) {
> - if (errno == EINTR)
> - continue;
> warning("writing to file");
> return -errno;
> }
next prev parent reply other threads:[~2017-06-21 13:26 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 0:27 [PATCH v3 0/6] trace-cmd: escape sequence, EINTR, error checking bug fixes Michael Sartain
2017-06-15 0:27 ` [PATCH v3 1/6] Fix bad force_token escape sequence Michael Sartain
2018-01-17 16:28 ` [tip:perf/core] tools lib traceevent: " tip-bot for Michael Sartain
2017-06-15 0:27 ` [PATCH v3 2/6] Fix unsigned return values being error checked as negative Michael Sartain
2017-06-15 0:27 ` [PATCH v3 3/6] Handle EINTR signal interrupts for read, write, open calls Michael Sartain
2017-06-21 13:26 ` Steven Rostedt [this message]
2017-06-15 0:27 ` [PATCH v3 4/6] Fix read / write data offsets in read / write loops Michael Sartain
2017-06-21 13:29 ` Steven Rostedt
2017-06-21 17:36 ` Michael Sartain
2017-06-15 0:28 ` [PATCH v3 5/6] Fix function prototypes for __vwarning, __vpr_stat, and __vdie Michael Sartain
2017-06-15 0:28 ` [PATCH v3 6/6] Fix cases where string literals were passed as string format args Michael Sartain
2017-08-02 22:15 [PATCH V3 1/2] use direname instead of custom code Federico Vaga
2017-08-02 22:15 ` [PATCH V3 2/2] It makes the code clearer and less error prone Federico Vaga
2017-08-14 17:33 ` Steven Rostedt
2017-08-15 7:25 ` Federico Vaga
2017-11-08 18:50 ` Steven Rostedt
2017-08-02 23:48 ` [PATCH V3 1/2] trace-cmd record: use direname instead of custom code Steven Rostedt
2017-08-14 17:14 ` [PATCH V3 1/2] " Steven Rostedt
2017-09-28 20:13 [PATCH][trace-cmd] Print value of unknown symbolic fields Jan Kiszka
2017-10-03 22:46 ` Steven Rostedt
2017-10-03 23:12 ` Steven Rostedt
2017-10-16 16:55 [PATCH v2 0/4] trace-cmd: Fixes for four minor bugs Michael Sartain
2017-10-16 16:55 ` [PATCH v2 1/4] trace-cmd: Fix incorrect malloc size arg: *item instead of item Michael Sartain
2017-10-16 16:55 ` [PATCH v2 2/4] trace-cmd: Fix NULL pointer being passed to memcpy Michael Sartain
2017-10-16 16:55 ` [PATCH v2 3/4] trace-cmd: Add UL suffix to MISSING_EVENTS since ints shouldn't be left shifted by 31 Michael Sartain
2017-10-16 16:55 ` [PATCH v2 4/4] trace-cmd: Use unsigned values in Hsieh's trace_hash fast hash function Michael Sartain
2018-01-12 0:47 [PATCH 00/10] tools lib traceveent: Pull updates from trace-cmd library Steven Rostedt
2018-01-12 0:47 ` [PATCH 01/10] lib, traceevent: Fix bad force_token escape sequence Steven Rostedt
2018-01-12 0:47 ` [PATCH 02/10] lib traceevent: Show value of flags that have not been parsed Steven Rostedt
2018-01-17 16:28 ` [tip:perf/core] tools " tip-bot for Steven Rostedt (VMware)
2018-01-12 0:47 ` [PATCH 03/10] lib traceevent: Print value of unknown symbolic fields Steven Rostedt
2018-01-17 16:28 ` [tip:perf/core] tools " tip-bot for Jan Kiszka
2018-01-12 0:47 ` [PATCH 04/10] lib traceevent: Simplify pointer print logic and fix %pF Steven Rostedt
2018-01-17 16:29 ` [tip:perf/core] tools " tip-bot for Steven Rostedt (VMware)
2018-01-12 0:47 ` [PATCH 05/10] lib traceevent: Handle new pointer processing of bprint strings Steven Rostedt
2018-01-17 16:29 ` [tip:perf/core] tools " tip-bot for Steven Rostedt (VMware)
2018-01-12 0:47 ` [PATCH 06/10] lib traceevent: Show contents (in hex) of data of unrecognized type records Steven Rostedt
2018-01-17 16:30 ` [tip:perf/core] tools " tip-bot for Steven Rostedt (VMware)
2018-01-12 0:47 ` [PATCH 07/10] lib traceevent: Use asprintf when possible Steven Rostedt
2018-01-17 16:30 ` [tip:perf/core] tools " tip-bot for Federico Vaga
2018-01-12 0:47 ` [PATCH 08/10] lib traceevent: Add UL suffix to MISSING_EVENTS Steven Rostedt
2018-01-17 16:31 ` [tip:perf/core] tools " tip-bot for Michael Sartain
2018-01-12 0:47 ` [PATCH 09/10] lib traceeevent: Fix missing break in FALSE case of pevent_filter_clear_trivial() Steven Rostedt
2017-04-26 14:55 ` [PATCH] parse-events: Fix the FALSE case in pevent_filter_clear_trivial() Taeung Song
2018-01-17 16:31 ` [tip:perf/core] tools lib traceevent: Fix missing break in FALSE case of pevent_filter_clear_trivial() tip-bot for Taeung Song
2018-01-12 1:00 ` [PATCH 09/10] lib traceeevent: " Taeung Song
2018-01-12 1:14 ` Steven Rostedt
2018-01-12 16:02 ` Arnaldo Carvalho de Melo
2018-01-12 0:47 ` [PATCH 10/10] lib traceevent: Fix get_field_str() for dynamic strings Steven Rostedt
2018-01-17 16:31 ` [tip:perf/core] tools " tip-bot for Steven Rostedt (VMware)
2018-01-17 6:02 ` [PATCH 00/10] tools lib traceveent: Pull updates from trace-cmd library Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170621092623.5b85244e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikesart@fastmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).