timeout switch for actsync

Julien ÉLIE julien at trigofacile.com
Wed Jul 6 16:37:12 UTC 2011


Hi Florian,

> Reading around a little,
> I found yet another approach to my problem: Why don't we set a timeout
> on the network socket when we create it? connect() seems to make use of
> a timeout, but after that, other reads/writes block indefinitely by
> default.

Is it really portable?
I doubt SO_RCVTIMEO and SO_SNDTIMEO are defined on all platforms.



> Something like this:
>
> "actsync: cannot connect to server: Resource temporarily unavailable"
>
> doesn't sound too misleading?

I believe it is fine.



> --- a/lib/network.c
> +++ b/lib/network.c
> @@ -435,6 +435,9 @@ network_connect(struct addrinfo *ai, const char *source)
>       int fd = -1;
>       int oerrno;
>       bool success;
> +    struct timeval connect_timeout;
> +    connect_timeout.tv_sec = 300;
> +    connect_timeout.tv_usec = 0;
[...]
> +    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &connect_timeout, sizeof(connect_timeout)) != 0) {
> +        syswarn("setsockopt SO_RCVTIMEO 300 failed");
> +        /*return false;<- not needed, as failure would just be like before? */
> +    }

Maybe with an "#ifdef SO_RCVTIMEO" so that it is taken into account on 
systems having such a feature?



> And what should such a compulsory timeout be, 300s like TCP or
> rather something shorter like 30s?

We should use DEFAULT_TIMEOUT (set in include/inn/options.h to 300).

-- 
Julien ÉLIE

« Cinq millions et demi de conducteurs français ont une mauvaise vue.
   Heureusement, leur nombre diminue de jour en jour. » (Coluche)



More information about the inn-workers mailing list