timeout switch for actsync
Florian Schlichting
fschlich at CIS.FU-Berlin.DE
Thu Jul 7 00:20:37 UTC 2011
Hi Julien,
> >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.
I have no experience at all when it comes to porting and portability.
Would anyone happen to know good resources on this topic in general?
> >--- 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?
I think that's a good solution; we're adding a feature for those who can
use it, everybody else keeps getting what they always had. I'm happy and
nobody get's hurt :-)
> >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).
agreed.
Florian
More information about the inn-workers
mailing list