Service-utils.inc :: line 90, sleep(2) not long enough



  • Hi all,

    I think I have found a bug in the combination of squids rc file and service-utils.inc
    Not sure which forum was best to post this in.

    Anyway,

    2.0.1-RELEASE (amd64)
    built on Mon Dec 12 18:16:13 EST 2011
    FreeBSD 8.1-RELEASE-p6
    squid-2.7.9_3
    squidGuard-1.4_4

    I found that squid (and squidGuard) wouldn't start on reboot nor from the services page.

    The issue is, on line 90 of said file we have:

            /* make sure service is stopped before starting */
            stop_service($name);
            sleep(2);
    
            if(file_exists("{$rcfileprefix}{$name}.sh")) {
                    mwexec_bg("/bin/sh {$rcfileprefix}{$name}.sh start");
                    return;
    
    

    But it takes longer than 2 seconds to execute the stop process.

    \time /usr/local/etc/rc.d/squid.sh  stop
            5.01 real         0.00 user         0.00 sys
    
    

    The reason why is on line 15 in /usr/local/etc/rc.d/squid.sh there is:

    sleep 5
    

    The stop is launched, waits 5 seconds, meanwhile the main process waits 2 seconds and launches squid, then the stop process kicks in and kills it all.

    Setting

            sleep(2); 
    

    in service-utils.inc to

            sleep(6);
    

    or greater solves the problem.


Log in to reply