mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net: add failed addresses + details on connect errors, make connect more robust in the default non blocking mode (#15364)
This commit is contained in:
@ -269,6 +269,7 @@ fn simple_tcp_client(config SimpleTcpClientConfig) ?string {
|
||||
mut tries := 0
|
||||
for tries < config.retries {
|
||||
tries++
|
||||
eprintln('> client retries: $tries')
|
||||
client = net.dial_tcp(localserver) or {
|
||||
if tries > config.retries {
|
||||
return err
|
||||
@ -278,6 +279,10 @@ fn simple_tcp_client(config SimpleTcpClientConfig) ?string {
|
||||
}
|
||||
break
|
||||
}
|
||||
if client == unsafe { nil } {
|
||||
eprintln('coult not create a tcp client connection to $localserver after $config.retries retries')
|
||||
exit(1)
|
||||
}
|
||||
client.set_read_timeout(tcp_r_timeout)
|
||||
client.set_write_timeout(tcp_w_timeout)
|
||||
defer {
|
||||
|
@ -21,7 +21,7 @@ struct Config {
|
||||
|
||||
fn exit_after_timeout(timeout_in_ms int) {
|
||||
time.sleep(timeout_in_ms * time.millisecond)
|
||||
// eprintln('webserver is exiting ...')
|
||||
println('>> webserver: pid: $os.getpid(), exiting ...')
|
||||
exit(0)
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ fn main() {
|
||||
timeout: timeout
|
||||
global_config: config
|
||||
}
|
||||
eprintln('>> webserver: started on http://localhost:$app.port/ , with maximum runtime of $app.timeout milliseconds.')
|
||||
eprintln('>> webserver: pid: $os.getpid(), started on http://localhost:$app.port/ , with maximum runtime of $app.timeout milliseconds.')
|
||||
vweb.run_at(app, host: 'localhost', port: http_port, family: .ip)?
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user