Fix a possible deadlock in TCP accepting

Each network thread holds an array of locks, indexed by a hash
of fd. When we accept a connection we hold a lock in accepting thread.
We then generate the thread number and lock bucket for the new
connection socket - if we hit the same thread and lock bucket as
accepting socket we get a deadlock. Avoid this by checking if we're
in the same thread/lock bucket and not locking in this case.
39 jobs for !1958 with 1046-deadlock-in-tcp-code in 10 minutes and 55 seconds (queued for 3 seconds)
detached
Status Job ID Name Coverage
  Precheck
passed 🐞:sid:amd64 #235884
amd64 linux

00:00:12

passed misc:sid:amd64 #235883
amd64 linux

00:00:17

 
  Build
passed asan:sid:amd64 #235895
amd64 linux

00:02:50

passed clang:stretch:amd64 #235896
amd64 linux

00:01:46

passed clang:stretch:i386 #235897
i386 linux

00:01:50

passed docs:sid:amd64 #235885
amd64 linux

00:00:45

passed gcc:bionic:amd64 #235894
amd64 linux

00:01:38

passed gcc:centos6:amd64 #235886
amd64 linux

00:01:50

passed gcc:centos7:amd64 #235887
amd64 linux

00:01:59

passed gcc:fedora29:amd64 #235892
amd64 linux

00:02:34

passed gcc:jessie:amd64 #235888
amd64 linux

00:01:21

passed gcc:sid:amd64 #235890
amd64 linux

00:01:34

passed gcc:sid:i386 #235891
i386 linux

00:01:38

passed gcc:stretch:amd64 #235889
amd64 linux

00:01:42

passed gcc:xenial:amd64 #235893
amd64 linux

00:01:24

passed pkcs11:sid:amd64 #235898
amd64 linux

00:01:26

 
  Test
passed system:asan:sid:amd64 #235917
amd64 linux

00:07:47

passed system:gcc:bionic:amd64 #235915
amd64 linux

00:06:21

passed system:gcc:centos6:amd64 #235899
amd64 linux

00:06:25

passed system:gcc:centos7:amd64 #235901
amd64 linux

00:06:28

passed system:gcc:fedora29:amd64 #235911
amd64 linux

00:06:25

passed system:gcc:jessie:amd64 #235903
amd64 linux

00:06:34

passed system:gcc:sid:amd64 #235907
amd64 linux

00:06:56

passed system:gcc:sid:i386 #235909
i386 linux

00:06:27

passed system:gcc:stretch:amd64 #235905
amd64 linux

00:06:35

passed system:gcc:xenial:amd64 #235913
amd64 linux

00:06:45

passed system:pkcs11:sid:amd64 #235920
amd64 linux

00:06:41

passed unit:asan:sid:amd64 #235918
amd64 linux

00:01:11

passed unit:clang:stretch:amd64 #235919
amd64 linux

00:00:59

passed unit:gcc:bionic:amd64 #235916
amd64 linux

00:01:00

passed unit:gcc:centos6:amd64 #235900
amd64 linux

00:00:48

passed unit:gcc:centos7:amd64 #235902
amd64 linux

00:00:49

passed unit:gcc:fedora29:amd64 #235912
amd64 linux

00:01:04

passed unit:gcc:jessie:amd64 #235904
amd64 linux

00:00:30

passed unit:gcc:sid:amd64 #235908
amd64 linux

00:00:45

passed unit:gcc:sid:i386 #235910
i386 linux

00:00:59

passed unit:gcc:stretch:amd64 #235906
amd64 linux

00:01:00

passed unit:gcc:xenial:amd64 #235914
amd64 linux

00:01:04

passed unit:pkcs11:sid:amd64 #235921
amd64 linux

00:01:02