authorgravatar for git@l4.pmLuna <git@l4.pm> 2019-11-29 17:36:05-03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-30 19:26:30-05:00
log0e67568bcac0c4aea795969e2c8b733326b87bec
treee18f13a10540666d7d51d5e0de7208265ab2ad83
parent4a4d2c0d80443a00945beeff4e3acaa9e7ea59cb
signature Commit is signed but in an unrecognized format.

net: fix Options

- os: fix typos on setsockopt

2 files changed, 5 insertions(+), 5 deletions(-)

lib/std/net.zig+3-1
...@@ -1279,6 +1279,7 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8)...@@ -1279,6 +1279,7 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8)
1279pub const StreamServer = struct {1279pub const StreamServer = struct {
1280 /// Copied from `Options` on `init`.1280 /// Copied from `Options` on `init`.
1281 kernel_backlog: u32,1281 kernel_backlog: u32,
1282 reuse_address: bool,
12821283
1283 /// `undefined` until `listen` returns successfully.1284 /// `undefined` until `listen` returns successfully.
1284 listen_address: Address,1285 listen_address: Address,
...@@ -1301,6 +1302,7 @@ pub const StreamServer = struct {...@@ -1301,6 +1302,7 @@ pub const StreamServer = struct {
1301 return StreamServer{1302 return StreamServer{
1302 .sockfd = null,1303 .sockfd = null,
1303 .kernel_backlog = options.kernel_backlog,1304 .kernel_backlog = options.kernel_backlog,
1305 .reuse_address = options.reuse_address,
1304 .listen_address = undefined,1306 .listen_address = undefined,
1305 };1307 };
1306 }1308 }
...@@ -1323,7 +1325,7 @@ pub const StreamServer = struct {...@@ -1323,7 +1325,7 @@ pub const StreamServer = struct {
1323 self.sockfd = null;1325 self.sockfd = null;
1324 }1326 }
13251327
1326 if (self.options.reuse_address) {1328 if (self.reuse_address) {
1327 var optval: c_int = 1;1329 var optval: c_int = 1;
1328 try os.setsockopt(1330 try os.setsockopt(
1329 self.sockfd.?,1331 self.sockfd.?,
lib/std/os.zig+2-4
...@@ -3252,16 +3252,14 @@ pub fn sched_yield() SchedYieldError!void {...@@ -3252,16 +3252,14 @@ pub fn sched_yield() SchedYieldError!void {
3252}3252}
32533253
3254/// Set a socket's options.3254/// Set a socket's options.
3255pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) SetSockOptError!void {3255pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) !void {
3256 const rc = system.setsockopt();
3257
3258 switch (errno(system.setsockopt(fd, level, optname, optval, optlen))) {3256 switch (errno(system.setsockopt(fd, level, optname, optval, optlen))) {
3259 0 => {},3257 0 => {},
3260 EBADF => unreachable,3258 EBADF => unreachable,
3261 EINVAL => unreachable,3259 EINVAL => unreachable,
3262 EDOM => return error.TimeoutTooBig,3260 EDOM => return error.TimeoutTooBig,
3263 EISCONN => return error.AlreadyConnected,3261 EISCONN => return error.AlreadyConnected,
3264 ENOPROTOOOPT => return error.InvalidProtocolOption,3262 ENOPROTOOPT => return error.InvalidProtocolOption,
3265 ENOTSOCK => return error.NotSocket,3263 ENOTSOCK => return error.NotSocket,
32663264
3267 ENOMEM => return error.OutOfMemory,3265 ENOMEM => return error.OutOfMemory,