linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: linux-btrace@vger.kernel.org
Subject: Re: Question: blktrace server mode & orderly shut down
Date: Fri, 06 Feb 2009 08:03:01 +0000	[thread overview]
Message-ID: <20090206080301.GT30821@kernel.dk> (raw)
In-Reply-To: <4988C599.6070909@hp.com>

On Tue, Feb 03 2009, Alan D. Brunelle wrote:
> According to the recv(2) man page:
> 
> The return value will be 0 when the peer has performed an orderly
> shutdown.
> 
> Yet the code in read_data_net and net_get_header both attempt to re-read
> from a socket that will _never_ have data. (I hit this problem today on
> blktrace2 - I've got orderly shut downs in place.)
> 
> Does this pseudo-patch break something?
> 
> diff --git a/blktrace.c b/blktrace.c
> index c55b491..9ef7313 100644
> --- a/blktrace.c
> +++ b/blktrace.c
> @@ -550,7 +550,7 @@ static int read_data_net(struct thread_information
> *tip, voi
>                 ret = recv(nc->in_fd, buf, bytes_left, MSG_WAITALL);
> 
>                 if (!ret)
> -                       continue;
> +                       return 0;
>                 else if (ret < 0) {
>                         if (errno != EAGAIN) {
>                                 perror(tip->fn);
> @@ -1466,8 +1466,7 @@ static int net_get_header(struct net_connection *nc,
>                         usleep(1000);
>                         continue;
>                 } else if (!ret) {
> -                       usleep(1000);
> -                       continue;
> +                       return 0;
>                 } else {
>                         p += ret;
>                         bytes_left -= ret;

My bad, I think the patch looks correct. Feel free to commit it, you can
add my acked-by to it.

-- 
Jens Axboe


  reply	other threads:[~2009-02-06  8:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-03 22:30 Question: blktrace server mode & orderly shut down Alan D. Brunelle
2009-02-06  8:03 ` Jens Axboe [this message]
2009-02-06 11:36 ` Alan D. Brunelle

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=20090206080301.GT30821@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=linux-btrace@vger.kernel.org \
    /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).