All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 1/2] add tst_get_unused_port()
Date: Sun, 09 Mar 2014 19:40:52 -0400	[thread overview]
Message-ID: <10580235.j7E8ls0tGP@vapier> (raw)
In-Reply-To: <b187cebc670c5e8d23f2405d95f82405a0416095.1394190599.git.jstancek@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 754 bytes --]

On Fri 07 Mar 2014 12:39:24 Jan Stancek wrote:
> Returns unused port number for specified domain/type.

the new func isn't race free, but it is way better than the current code, and 
the race is pretty small.  so LGTM.

> +unsigned short tst_get_unused_port(unsigned short family, int type,
> +	void (cleanup_fn)(void))
> +{
> +	int sock;
> +	struct sockaddr_in addr4;
> +	struct sockaddr_in6 addr6;

the current code works, but isn't the point of sockaddr_storage to avoid this 
duplicated storage logic ?  so you could just do:
	struct sockaddr_storage _addr;
	struct sockaddr *addr = (struct sockaddr *)&_addr;
	struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
	struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 451 bytes --]

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2014-03-09 23:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 11:39 [LTP] [PATCH 0/2] do not pick free/unused port by chance Jan Stancek
2014-03-07 11:39 ` [LTP] [PATCH 1/2] add tst_get_unused_port() Jan Stancek
2014-03-09 23:40   ` Mike Frysinger [this message]
2014-03-10 14:22   ` [LTP] (no subject) Jan Stancek
2014-03-10 14:28   ` [LTP] [PATCH v2 1/2] add tst_get_unused_port() Jan Stancek
2014-03-11 15:24     ` chrubis
2014-03-07 11:39 ` [LTP] [PATCH 2/2] do not pick free/unused port by chance Jan Stancek

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=10580235.j7E8ls0tGP@vapier \
    --to=vapier@gentoo.org \
    --cc=ltp-list@lists.sourceforge.net \
    /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.