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:
parent
00bd7b621d
commit
9241b5572b
@ -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',
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user