Skip to content

Commit c5322f7

Browse files
committed
f clean up discussion of file-descriptor use and recommend not doing it
1 parent 466f396 commit c5322f7

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,12 @@ pub struct MessageHandler<CM: Deref, RM: Deref> where
178178
///
179179
/// For efficiency, Clone should be relatively cheap for this type.
180180
///
181-
/// If applicable in your language, you probably want to just extend an int and put a file
182-
/// descriptor in a struct and implement this trait on it. Note, of course, that if you do so and
183-
/// have multiple threads interacting with the [`PeerManager`], you must not call `close()` on the
184-
/// file descriptor until all threads are guaranteed to not call any [`PeerManager`] functions with
185-
/// the same descriptor. Otherwise, file descriptor re-use could imply that you call a
186-
/// [`PeerManager`] function with a file descriptor representing a different connection.
187-
///
188-
/// Note that if you are using a higher-level net library that may call close() itself when you
189-
/// close a socket, be careful to ensure you don't directly use the file descriptor for your [`Eq`]
190-
/// and [`Hash`] implementations.
181+
/// Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original
182+
/// has been disconnected, the [`PeerManager`] informed of the disconnection (either by it having
183+
/// triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no further
184+
/// calls to the [`PeerManager`] related to the original socket occur. This allows you to use a
185+
/// file descriptor for your SocketDescriptor directly, however for simplicity you may wish to
186+
/// simply use another value which is guaranteed to be globally unique instead.
191187
pub trait SocketDescriptor : cmp::Eq + hash::Hash + Clone {
192188
/// Attempts to send some data from the given slice to the peer.
193189
///

0 commit comments

Comments
 (0)