Skip to content

Commit 9e49062

Browse files
committed
f clean up discussion of file-descriptor use and recommend not doing it
1 parent 4c89ae4 commit 9e49062

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

0 commit comments

Comments
 (0)