1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.http: skip network timeouts on socket accept in the main http.Server loop

This commit is contained in:
Delyan Angelov 2022-10-23 17:08:16 +03:00
parent 00bd7b621d
commit 9241b5572b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 5 additions and 6 deletions

View File

@ -1,11 +1,8 @@
module net
const (
errors_base = 0
)
// Well defined errors that are returned from socket functions
pub const (
errors_base = 0
err_new_socket_failed = error_with_code('net: new_socket failed to create socket',
errors_base + 1)
err_option_not_settable = error_with_code('net: set_option_xxx option not settable',

View File

@ -51,9 +51,11 @@ pub fn (mut s Server) listen_and_serve() {
break
}
mut conn := s.listener.accept() or {
if err.msg() != 'net: op timed out' {
eprintln('accept() failed: $err; skipping')
if err.code() == net.err_timed_out_code {
// just skip network timeouts, they are normal
continue
}
eprintln('accept() failed, reason: $err; skipping')
continue
}
conn.set_read_timeout(s.read_timeout)