Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: jeremie.galarneau@efficios.com (Jérémie Galarneau)
Subject: [lttng-dev] [PATCH lttng-tools] Fix: set errno with value from SO_ERROR on error.
Date: Tue, 27 Feb 2018 11:17:58 -0500	[thread overview]
Message-ID: <20180227161757.GD1647@gmail.com> (raw)
In-Reply-To: <1519182391-24817-1-git-send-email-jonathan.rajotte-julien@efficios.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2421 bytes --]

Merged in master, stable-2.10, and stable-2.9.

Thanks,
Jérémie

On Tue, Feb 20, 2018 at 10:06:31PM -0500, Jonathan Rajotte wrote:
> Debugging output at the same time in case of asynchronous handling.
> 
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  src/common/sessiond-comm/inet.c  | 6 ++++++
>  src/common/sessiond-comm/inet6.c | 7 +++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c
> index 25dbd21..0e72bb7 100644
> --- a/src/common/sessiond-comm/inet.c
> +++ b/src/common/sessiond-comm/inet.c
> @@ -176,6 +176,8 @@ int connect_with_timeout(struct lttcomm_sock *sock)
>  		goto success;
>  	}
>  
> +	DBG("Asynchronous connect for sock %d, performing polling with"
> +			" timeout: %lums", sock->fd, timeout);
>  	/*
>  	 * Perform poll loop following EINPROGRESS recommendation from
>  	 * connect(2) man page.
> @@ -202,12 +204,16 @@ int connect_with_timeout(struct lttcomm_sock *sock)
>  			ret = getsockopt(sock->fd, SOL_SOCKET,
>  				SO_ERROR, &optval, &optval_len);
>  			if (ret) {
> +				PERROR("getsockopt");
>  				goto error;
>  			}
>  			if (!optval) {
> +				/* errno is set to zero from getsockopt */
>  				connect_ret = 0;
>  				goto success;
>  			} else {
> +				/* Get actual connect() errno from opt_val */
> +				errno = optval;
>  				goto error;
>  			}
>  		}
> diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c
> index 0b0383c..071fd52 100644
> --- a/src/common/sessiond-comm/inet6.c
> +++ b/src/common/sessiond-comm/inet6.c
> @@ -174,6 +174,9 @@ int connect_with_timeout(struct lttcomm_sock *sock)
>  		goto success;
>  	}
>  
> +	DBG("Asynchronous connect for sock %d, performing polling with"
> +			" timeout: %lums", sock->fd, timeout);
> +
>  	/*
>  	 * Perform poll loop following EINPROGRESS recommendation from
>  	 * connect(2) man page.
> @@ -200,12 +203,16 @@ int connect_with_timeout(struct lttcomm_sock *sock)
>  			ret = getsockopt(sock->fd, SOL_SOCKET,
>  				SO_ERROR, &optval, &optval_len);
>  			if (ret) {
> +				PERROR("getsockopt");
>  				goto error;
>  			}
>  			if (!optval) {
> +				/* errno is set to zero from getsockopt */
>  				connect_ret = 0;
>  				goto success;
>  			} else {
> +				/* Get actual connect() errno from opt_val */
> +				errno = optval;
>  				goto error;
>  			}
>  		}
> -- 
> 2.7.4
> 


           reply	other threads:[~2018-02-27 16:17 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1519182391-24817-1-git-send-email-jonathan.rajotte-julien@efficios.com>]

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=20180227161757.GD1647@gmail.com \
    --to=jeremie.galarneau@efficios.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