net: simplify TcpListener.accept, use `C.accept(l.sock.handle, 0, 0)`, since we do not care about the local address of the accepted connection

pull/14006/head
Delyan Angelov 2022-04-12 11:47:41 +03:00
parent 716cb17aea
commit 9b43713ec5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 2 additions and 8 deletions

View File

@ -239,16 +239,10 @@ pub fn (mut l TcpListener) accept() ?&TcpConn {
$if trace_tcp ? { $if trace_tcp ? {
eprintln(' TcpListener.accept | l.sock.handle: ${l.sock.handle:6}') eprintln(' TcpListener.accept | l.sock.handle: ${l.sock.handle:6}')
} }
addr := Addr{ mut new_handle := C.accept(l.sock.handle, 0, 0)
addr: AddrData{
Ip6: Ip6{}
}
}
size := sizeof(Addr)
mut new_handle := C.accept(l.sock.handle, voidptr(&addr), &size)
if new_handle <= 0 { if new_handle <= 0 {
l.wait_for_accept() ? l.wait_for_accept() ?
new_handle = C.accept(l.sock.handle, voidptr(&addr), &size) new_handle = C.accept(l.sock.handle, 0, 0)
if new_handle == -1 || new_handle == 0 { if new_handle == -1 || new_handle == 0 {
return error('accept failed') return error('accept failed')
} }