Race condition on restart

David While dwhile at while.org.uk
Fri Apr 28 08:53:59 UTC 2017


Done


On 28/04/2017 05:57, Jerry Benton wrote:
> If someone will create a pull request on GitHub I will implement it.
>
> -
> Jerry Benton
> www.mailborder.com <http://www.mailborder.com>
> +1 - 844-436-6245
>
>
>
>> On Apr 28, 2017, at 12:54 AM, Paul Scott <sales at edenusa.com 
>> <mailto:sales at edenusa.com>> wrote:
>>
>> This is exactly what I thought.  Every time I restarted MailScanner, 
>> it caused this problem and the system had to be restarted.
>>
>> Sincerely,
>>
>> Paul Scott, Engineer
>> Eden USA, Incorporated
>> Event Production Services Since 1995
>> Los Angeles-Las Vegas-New York
>> sales at edenusa.com <mailto:sales at edenusa.com> OR 
>> edenusasales at gmail.com <mailto:edenusasales at gmail.com>
>> Telephone(s): 866.501.3336 OR 951.505.6967
>> Fax: 866.502.3336
>>
>> WEBSITE: https://www.edenusa.com
>> FACEBOOK: http://www.facebook.com/edenusainc
>>
>> -----Original Message-----
>> From: MailScanner 
>> [mailto:mailscanner-bounces+sales=edenusa.com at lists.mailscanner.info] 
>> On Behalf Of David While
>> Sent: Wednesday, April 26, 2017 9:39 AM
>> To: mailscanner at lists.mailscanner.info 
>> <mailto:mailscanner at lists.mailscanner.info>
>> Subject: Race condition on restart
>>
>> There is a bug in MailScanner which leads to a race condition.
>>
>> The init script which starts/stops & restarts MailScanner removes the 
>> PID file when MailScanner is stopped.
>>
>> Unfortunately when MailScanner is issued with a SIGTERM (when issuing 
>> a restart or stop) then it also removes the PID file (line 1419 in 
>> MailScanner).
>>
>> What is happening is that the init script issues the kill and then 
>> continues. This doesn't kill MailScanner but simply sends the signal.
>> MailScanner does some processing before dying. Consequently there is 
>> now a race as to who will remove the PID file. The worst case is that 
>> it is removed after MailScanner has been restarted. This leads to the 
>> hourly ms-check constantly restarting MailScanner.
>>
>> I fixed this in the init script by:
>>
>> 1. Removing the following lines from do_stop
>>
>>                     # remove pid file
>>                     if [ -f $PIDFILE ] ; then
>>                                 rm -f $PIDFILE
>>                         fi
>>
>> 2. Moving the following lines from restart to do_stop where the above 
>> lines were removed
>>
>>         s='-\|/';
>>         x=0
>>         i=0
>>         while [ "$x" -lt 300 -a -f $PIDFILE ]; do
>>            x=$((x+1));
>>            i=$(( (i+1) %4 ));
>>            printf "\r${s:$i:1}";
>>            sleep .1;
>>         done
>>
>> What this does is wait for MailScanner to die and remove the PID file 
>> before continuing.
>>
>> I don't think this is a permament fix as there ought to be a check 
>> that it has not timed out before continuing.
>>
>> David While
>>
>>
>>
>> --
>> MailScanner mailing list
>> mailscanner at lists.mailscanner.info 
>> <mailto:mailscanner at lists.mailscanner.info>
>> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>>
>>
>>
>> -- 
>> MailScanner mailing list
>> mailscanner at lists.mailscanner.info
>> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>>
>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mailscanner.info/pipermail/mailscanner/attachments/20170428/811d8094/attachment.html>


More information about the MailScanner mailing list