net: fix Options

- os: fix typos on setsockopt
master
Luna 2019-11-29 17:36:05 -03:00 committed by Andrew Kelley
parent 4a4d2c0d80
commit 0e67568bca
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 5 additions and 5 deletions

View File

@ -1279,6 +1279,7 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8)
pub const StreamServer = struct {
/// Copied from `Options` on `init`.
kernel_backlog: u32,
reuse_address: bool,
/// `undefined` until `listen` returns successfully.
listen_address: Address,
@ -1301,6 +1302,7 @@ pub const StreamServer = struct {
return StreamServer{
.sockfd = null,
.kernel_backlog = options.kernel_backlog,
.reuse_address = options.reuse_address,
.listen_address = undefined,
};
}
@ -1323,7 +1325,7 @@ pub const StreamServer = struct {
self.sockfd = null;
}
if (self.options.reuse_address) {
if (self.reuse_address) {
var optval: c_int = 1;
try os.setsockopt(
self.sockfd.?,

View File

@ -3252,16 +3252,14 @@ pub fn sched_yield() SchedYieldError!void {
}
/// Set a socket's options.
pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) SetSockOptError!void {
const rc = system.setsockopt();
pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) !void {
switch (errno(system.setsockopt(fd, level, optname, optval, optlen))) {
0 => {},
EBADF => unreachable,
EINVAL => unreachable,
EDOM => return error.TimeoutTooBig,
EISCONN => return error.AlreadyConnected,
ENOPROTOOOPT => return error.InvalidProtocolOption,
ENOPROTOOPT => return error.InvalidProtocolOption,
ENOTSOCK => return error.NotSocket,
ENOMEM => return error.OutOfMemory,