nim-libp2p/libp2p
Jacek Sieka f46bf0faa4
remove send lock (#334)
* remove send lock

When mplex receives data it will block until a reader has processed the
data. Thus, when a large message is received, such as a gossipsub
subscription table, all of mplex will be blocked until all reading is
finished.

However, if at the same time a `dial` to establish a gossipsub send
connection is ongoing, that `dial` will be blocked because mplex is no
longer reading data - specifically, it might indeed be the connection
that's processing the previous data that is waiting for a send
connection.

There are other problems with the current code:
* If an exception is raised, it is not necessarily raised for the same
connection as `p.sendConn`, so resetting `p.sendConn` in the exception
handling is wrong
* `p.isConnected` is checked before taking the lock - thus, if it
returns false, a new dial will be started. If a new task enters `send`
before dial is finished, it will also determine `p.isConnected` is
false, then get stuck on the lock - when the previous task finishes and
releases the lock, the new task will _also_ dial and thus reset
`p.sendConn` causing a leak.

* prefer existing connection

simplifies flow
2020-08-17 12:38:27 +02:00
..
crypto Refactor minasn1 and fix security issues. (#323) 2020-08-11 16:58:51 -06:00
daemon Peer resultification and defect only (#245) 2020-07-01 08:25:09 +02:00
muxers simplify mplex (#327) 2020-08-15 07:58:30 +02:00
protobuf Minprotobuf refactoring 2 (#269) 2020-07-15 10:25:39 +02:00
protocols remove send lock (#334) 2020-08-17 12:38:27 +02:00
stream logging cleanups and small fixes (#331) 2020-08-15 21:50:31 +02:00
transports Fix build, add some raises (#315) 2020-08-05 19:30:57 -06:00
cid.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
connmanager.nim logging cleanups and small fixes (#331) 2020-08-15 21:50:31 +02:00
errors.nim Fix build, add some raises (#315) 2020-08-05 19:30:57 -06:00
multiaddress.nim Minprotobuf refactoring 2 (#269) 2020-07-15 10:25:39 +02:00
multibase.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
multicodec.nim Crypto utilities resultification (#150) 2020-05-18 07:25:55 +02:00
multihash.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
multistream.nim logging cleanups and small fixes (#331) 2020-08-15 21:50:31 +02:00
peerid.nim Minprotobuf refactoring 2 (#269) 2020-07-15 10:25:39 +02:00
peerinfo.nim peer hooks -> events (#320) 2020-08-08 08:52:20 +02:00
standard_setup.nim Rework pubsub (#322) 2020-08-11 18:05:49 -06:00
switch.nim Rework pubsub (#322) 2020-08-11 18:05:49 -06:00
transcoder.nim add side effect annotations (#197) 2020-06-01 09:25:16 +02:00
utility.nim Less verbose traces (#112) 2020-03-23 15:03:36 +09:00
varint.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
vbuffer.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00
wire.nim Less exceptions more results (#188) 2020-05-31 16:22:49 +02:00