SourceForge has been redesigned. Learn more.
Close

#40 Timeout option doesn't prevent hangs

current_version
closed
wimpunk
Other (17)
4
2013-10-28
2008-09-16
kostos
No

Hi,
i have Aolynk DR814 ADSL modem which is hanging from time to time and wifi-router (Dlink) connected between ADSL modem and server running ddclient.

In this configiration, when ADSL modem hangs, ddclient also hanging with message like " ddclient - read from 192.168.1.1 .." and still hanged infinitely, even after modem restarted, regardless timeout option is set.

As W/A i have changed the source code line below:

local $SIG{'ALRM'} = sub { $timeout = 1; };

to close socket descriptor when timeout happens:

local $SIG{'ALRM'} = sub { $timeout = 1; close($sd);};

Not sure is it good enough solution, but after week of testing (2 or 3 hangs happened) - it seem working, ddclient didn't hang since. Could you please check if it possible to include similar change into release?

P.S.
Could you also please consider small extension of functionality: in my feeling, it would be not too bad idea to log error message when timeout happens, or even better - to call external script given by option parameter to try to fix the issue.

Discussion

  • kostos

    kostos - 2008-09-16
    • priority: 5 --> 4
     
  • Cyril VINH-TUNG

    Cyril VINH-TUNG - 2009-08-16

    Hello

    I have exactly the same problem with web checkip.

    ddclient hangs at :
    CONNECT: checkip.dyndns.org
    CONNECTED: using HTTP
    SENDING: GET / HTTP/1.0
    SENDING: Host: checkip.dyndns.org
    SENDING: User-Agent: ddclient/3.7.3
    SENDING: Connection: close
    SENDING:

    I tried to modify the script with
    local $SIG{'ALRM'} = sub { $timeout = 1; close($sd);};

    but I have a segfault after timeout (20s) and ddclient daemon crashes :

    Aug 16 07:41:53 videosurvey ddclient[8215]: CONNECT: checkip.dyndns.org
    Aug 16 07:41:54 videosurvey ddclient[8215]: CONNECTED: using HTTP
    Aug 16 07:41:54 videosurvey ddclient[8215]: SENDING: GET / HTTP/1.0
    Aug 16 07:41:54 videosurvey ddclient[8215]: SENDING: Host: checkip.dyndns.org
    Aug 16 07:41:54 videosurvey ddclient[8215]: SENDING: User-Agent: ddclient/3.7.3
    Aug 16 07:41:54 videosurvey ddclient[8215]: SENDING: Connection: close
    Aug 16 07:41:54 videosurvey ddclient[8215]: SENDING:
    Aug 16 07:42:14 videosurvey kernel: ddclient[8215]: segfault at 8 ip 002abf9c sp bfdb7a70 error 6 in libperl.so[101000+257000]

     
  • Panos

    Panos - 2009-10-16

    Hello I had the same problem and managed to solve it by changing the code a bit. The key is to use an eval/die pair to force the alarm signal to do what we want it to do, that is interrupt the read (http://perldoc.perl.org/perlipc.html#Signals).

    Around line 1816 (Commented out the original code):

    # my $timeout = 0;
    # local $SIG{'ALRM'} = sub { $timeout = 1; msg(qq{Alarm!\n});};

    # $0 = sprintf("%s - reading from %s port %s", $program, $peer, $port);
    # alarm(opt('timeout')) if opt('timeout') > 0;
    # while (!$timeout && ($_ = <$sd>)) {
    # $0 = sprintf("%s - read from %s port %s", $program, $peer, $port);
    # verbose("RECEIVE:", "%s", define($_, "<undefined>"));
    # $reply .= $_ if defined $_;
    # }
    # if (opt('timeout') > 0) {
    # alarm(0);
    # }

    $0 = sprintf("%s - reading from %s port %s", $program, $peer, $port);
    eval {
    local $SIG{'ALRM'} = sub { die "timeout";};
    alarm(opt('timeout')) if opt('timeout') > 0;
    while (($_ = <$sd>)) {
    $0 = sprintf("%s - read from %s port %s", $program, $peer, $port);
    verbose("RECEIVE:", "%s", define($_, "<undefined>"));
    $reply .= $_ if defined $_;
    }
    if (opt('timeout') > 0) {
    alarm(0);
    }
    };

    close($sd);

    # if ($timeout) {
    if ($@ and $@ =~ /timeout/) {
    warning("TIMEOUT: %s after %s seconds", $to, opt('timeout'));
    $reply = '';
    }

     
  • wimpunk

    wimpunk - 2013-10-28
    • status: open --> closed
    • Group: --> current_version
     
  • wimpunk

    wimpunk - 2013-10-28

    Should be fixed since [r114].

     

    Related

    Commit: [r114]


    Last edit: wimpunk 2013-10-28

Log in to post a comment.