It looks like the libc team cut a release just after @devnexen's last
PR. Switch to it. That makes it easier for downstream crates to use a
git dependency on Nix.
* Fix the value of optlen as passed to libc::setsockopt
Ever since the sockopt macro was written in
979faf0976 we've been passing the wrong
size for u8 and usize sockopts.
* Add tests for sockopt::IpMulticastTtl #2073
On Linux and Android, sockopt::IpMulticastTtl can be set for both IPv4
and IPv6 sockets, but not on FreeBSD.
---------
Co-authored-by: Alan Somers <asomers@gmail.com>
Co-authored-by: Simon B. Gasse <sgasse@users.noreply.github.com>
From [tcp](https://man7.org/linux/man-pages/man7/tcp.7.html) man page:
```
TCP_FASTOPEN_CONNECT (since Linux 4.11)
This option enables an alternative way to perform Fast
Open on the active side (client). When this option is
enabled, connect(2) would behave differently depending on
if a Fast Open cookie is available for the destination.
If a cookie is not available (i.e. first contact to the
destination), connect(2) behaves as usual by sending a SYN
immediately, except the SYN would include an empty Fast
Open cookie option to solicit a cookie.
If a cookie is available, connect(2) would return 0
immediately but the SYN transmission is deferred. A
subsequent write(2) or sendmsg(2) would trigger a SYN with
data plus cookie in the Fast Open option. In other words,
the actual connect operation is deferred until data is
supplied.
Note: While this option is designed for convenience,
enabling it does change the behaviors and certain system
calls might set different errno values. With cookie
present, write(2) or sendmsg(2) must be called right after
connect(2) in order to send out SYN+data to complete 3WHS
and establish connection. Calling read(2) right after
connect(2) without write(2) will cause the blocking socket
to be blocked forever.
The application should either set TCP_FASTOPEN_CONNECT
socket option before write(2) or sendmsg(2), or call
write(2) or sendmsg(2) with MSG_FASTOPEN flag directly,
instead of both on the same connection.
Here is the typical call flow with this new option:
s = socket();
setsockopt(s, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, 1, ...);
connect(s);
write(s); /* write() should always follow connect()
* in order to trigger SYN to go out. */
read(s)/write(s);
/* ... */
close(s);
```
* Added object for automatic unlock on drop.
* Added appropriate changelog file.
* Fixed doc error on `Flock`.
* Requested changes to make `fcntl::flock` private and OwnedFd instead of RawFd.
* Indent fix.
* Removed doc links to private item, updated imports.
* More import fixes.
* Format changes.
* Remove unused import for redox.
* Added `Flockable` trait per discussions, added tests for `Flock`.
* Simplified flock error conditionals.
* Added missing cfg flags for `Flockable`.
* Added missing cfg flags for impl of `Flockable` on `File`.
* Update src/fcntl.rs
Co-authored-by: SteveLauC <stevelauc@outlook.com>
* Updated `Flockable` comment per suggestion.
* Finalized `FlockArg` as enum and removed TODO accordingly, removed flock wrapper entirely.
* Implemented `Flockable` for `OwnedFd` as well.
* Fixed linting error.
* Updated changelog accordingly.
* Corrected errno logic in `Flock::lock`.
* Properly dropped inner type for `Flock`.
* Replaced `ManuallyDrop` with `Option` as inner `Flock` type to avoid double-free.
* Fixed linting errors.
* Removed unnecessary cfg condition, updated documentation.
* Modified Flock behavior for drop() and unlock().
* Reverted changes to original `flock()` and `FlockArg` for deprecation period, added EINVAL case if the unlock operation is given to `Flock::lock()`.
* Refactored `Flock` to wrap T directly and avoid a double-free after `unlock()` is used.
* Fixed linting errors.
* More linting fixes.
* Fixed example code for `Flock::unlock()`.
* Made requested changes.
* Removed duplicate import.
* Format change.
---------
Co-authored-by: SteveLauC <stevelauc@outlook.com>
From [man page](https://man7.org/linux/man-pages/man7/ip.7.html):
```
IP_BIND_ADDRESS_NO_PORT (since Linux 4.2)
Inform the kernel to not reserve an ephemeral port when
using bind(2) with a port number of 0. The port will
later be automatically chosen at connect(2) time, in a way
that allows sharing a source port as long as the 4-tuple
is unique.
```