All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Olga Kornievskaia <kolga@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] [nfs-utils] handle EINTR during connection establishment
Date: Sat, 16 Jan 2016 17:01:13 -0500	[thread overview]
Message-ID: <569ABDA9.6040607@RedHat.com> (raw)
In-Reply-To: <1452807265-36920-1-git-send-email-kolga@netapp.com>



On 01/14/2016 04:34 PM, Olga Kornievskaia wrote:
> both connect() and select() can receive EINTR signals that we need to
> recover from.
> 
> In Unix Network Programming, volume 1, section 5.9, W. Richard Stevens
> states:
> 
> What we are doing […] is restarting the interrupted system call ourself.
> This is fine for accept, along with the functions such as read, write,
> select and open. But there is one function that we cannot restart ourself:
> connect. If this function returns EINTR, we cannot call it again, as doing
> so will return an immediate error. When connect is interrupted by a caught
> signal and is not automatically restarted, we must call select to wait for
> the connection to complete,
> 
> Thus for connect() treat both EINPROGRESS and EINTR the same -- call
> select().
> 
> For select(), it should be re-tried again upon receiving EINTR.
> 
> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Committed... Nice work!! 

steved.

> ---
>  support/nfs/rpc_socket.c |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/support/nfs/rpc_socket.c b/support/nfs/rpc_socket.c
> index c14efe8..edd43cc 100644
> --- a/support/nfs/rpc_socket.c
> +++ b/support/nfs/rpc_socket.c
> @@ -215,7 +215,7 @@ static int nfs_connect_nb(const int fd, const struct sockaddr *sap,
>  	 * use it later.
>  	 */
>  	ret = connect(fd, sap, salen);
> -	if (ret < 0 && errno != EINPROGRESS) {
> +	if (ret < 0 && errno != EINPROGRESS && errno != EINTR) {
>  		ret = -1;
>  		goto done;
>  	}
> @@ -227,10 +227,16 @@ static int nfs_connect_nb(const int fd, const struct sockaddr *sap,
>  	FD_ZERO(&rset);
>  	FD_SET(fd, &rset);
>  
> -	ret = select(fd + 1, NULL, &rset, NULL, timeout);
> -	if (ret <= 0) {
> -		if (ret == 0)
> -			errno = ETIMEDOUT;
> +	while ((ret = select(fd + 1, NULL, &rset, NULL, timeout)) < 0) {
> +		if (errno != EINTR) {
> +			ret = -1;
> +			goto done;
> +		} else {
> +			continue;
> +		}
> +	}
> +	if (ret == 0) {
> +		errno = ETIMEDOUT;
>  		ret = -1;
>  		goto done;
>  	}
> 

      reply	other threads:[~2016-01-16 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14 21:34 [PATCH 1/1] [nfs-utils] handle EINTR during connection establishment Olga Kornievskaia
2016-01-16 22:01 ` Steve Dickson [this message]

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=569ABDA9.6040607@RedHat.com \
    --to=steved@redhat.com \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.