netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* listen(2) backlog changes in or around Linux 3.1?
@ 2012-10-12 23:40 enh
  2012-10-15 17:12 ` Venkat Venkatsubra
  0 siblings, 1 reply; 20+ messages in thread
From: enh @ 2012-10-12 23:40 UTC (permalink / raw)
  To: netdev

i used to use the following hack to unit test connect timeouts: i'd
call listen(2) on a socket and then deliberately connect (backlog + 3)
sockets without accept(2)ing any of the connections. (why 3? because
Stevens told me so, and experiment backed him up. see figure 4.10 in
his UNIX Network Programming.)

with "old" kernels, 2.6.35-ish to 3.0-ish, this worked great. my next
connect(2) to the same loopback port would hang indefinitely. i could
even unblock the connect by calling accept(2) in another thread. this
was awesome for testing.

in 3.1 on ARM, 3.2 on x86 (Ubuntu desktop), and 3.4 on ARM, this no
longer works. it doesn't seem to be as simple as "the constant is no
longer 3". my tests are now flaky. sometimes they work like they used
to, and sometimes an extra connect(2) will succeed. (or, if i'm in
non-blocking mode, my poll(2) will return with the non-blocking socket
that's trying to connect now ready.)

i'm guessing if this changed in 3.1 and is still changed in 3.4,
whatever's changed wasn't an accident. but i haven't been able to find
the right search terms to RTFM. i also finally got around to grepping
the kernel for the "+ 3", but wasn't able to find that. (so i'd be
interested to know where the old behavior came from too.)

my least worst workaround at the moment is to use one of RFC5737's
test networks, but that requires that the device have a network
connection, otherwise my connect(2)s fail immediately with
ENETUNREACH, which is no use to me. also, unlike my old trick, i've
got no way to suddenly "unblock" a slow connect(2) (this is useful for
unit testing the code that does the poll(2) part of the usual
connect-with-timeout implementation).
https://android-review.googlesource.com/#/c/44563/

hopefully someone here can shed some light on this? ideally someone
will have a workaround as good as my old trick. i realize i was
relying on undocumented behavior, and i'm happy to have to check
/proc/version and behave appropriately, but i'd really like a way to
keep my unit tests!

thanks,
 elliott

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-10-25 23:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 23:40 listen(2) backlog changes in or around Linux 3.1? enh
2012-10-15 17:12 ` Venkat Venkatsubra
2012-10-15 17:26   ` enh
2012-10-15 21:30     ` Venkat Venkatsubra
2012-10-16 23:31     ` enh
2012-10-18 16:00       ` Venkat Venkatsubra
2012-10-18 16:53         ` Venkat Venkatsubra
2012-10-18 17:20           ` enh
2012-10-19  6:02             ` Vijay Subramanian
2012-10-19  6:50               ` Eric Dumazet
2012-10-19  8:06                 ` Eric Dumazet
2012-10-19  9:14                   ` Vijay Subramanian
2012-10-19 10:29                     ` Eric Dumazet
2012-10-19 11:39                       ` Eric Dumazet
2012-10-22 20:00                       ` Vijay Subramanian
2012-10-22 20:08                         ` Eric Dumazet
2012-10-22 22:11                           ` Vijay Subramanian
2012-10-25 22:50                             ` Eric Dumazet
2012-10-25 23:16                               ` Vijay Subramanian
2012-10-18 16:54       ` Eric Dumazet

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).