[asterisk-bugs] [Asterisk 0015093]: [patch] astcanary: race when asterisk daemonizes

Asterisk Bug Tracker noreply at bugs.digium.com
Mon May 18 14:27:25 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=15093 
====================================================================== 
Reported By:                tzafrir
Assigned To:                tilghman
====================================================================== 
Project:                    Asterisk
Issue ID:                   15093
Category:                   General
Reproducibility:            random
Severity:                   minor
Priority:                   normal
Status:                     closed
Asterisk Version:           1.6.1.0 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             2009-05-13 04:33 CDT
Last Modified:              2009-05-18 14:27 CDT
====================================================================== 
Summary:                    [patch] astcanary: race when asterisk daemonizes
Description: 
I normally start asterisk daemonized (without -c and such).

Sometimes (I still can't reproduce it) I immediately get the EX-CANARY
message printed to the console. E.g.:

Starting Asterisk PBX: The canary is no more.  He has ceased to be!  He's
expired and gone to meet his maker!  He's a stiff!  Bereft of life, he
rests in peace.  His metabolic processes are now history!  He's off the
twig!  He's kicked the bucket.  He's shuffled off his mortal coil, run down
the curtain, and joined the bleeding choir invisible!!  THIS is an
EX-CANARY.  (Reducing priority)

Note that this must have been printed before Asterisk has been detached
from the console. The message itself is ast_log(LOG_WARNING).

What we basically have is:

canary_thread() {
  sleep(120)
  while(1) {
    if (no signs of life from canary)
      give the EX-CANARY message and quit;
  }
}

main:

  fork() {
    /* child */
    exec(astcanary)
  } {
    /* parent */
    ast_pthread_create_detached(canary_thread);
  }
  
  if (user asked to daemonize)
    daemon()
}


When running daemon(), we also fork. This does not interact well with
sleep(2) as the attached test program demonstrates.
====================================================================== 

---------------------------------------------------------------------- 
 (0104964) svnbot (reporter) - 2009-05-18 14:27
 https://issues.asterisk.org/view.php?id=15093#c104964 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 195357

_U  branches/1.6.0/
U   branches/1.6.0/main/asterisk.c

------------------------------------------------------------------------
r195357 | tilghman | 2009-05-18 14:27:24 -0500 (Mon, 18 May 2009) | 16
lines

Merged revisions 195320 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r195320 | tilghman | 2009-05-18 14:17:15 -0500 (Mon, 18 May 2009) | 9
lines
  
  Move the spawn of astcanary down, until after the call to daemon(3).
  This avoids possible conflicts with the internal implementation of
  daemon(3).
  (closes issue https://issues.asterisk.org/view.php?id=15093)
   Reported by: tzafrir
   Patches: 
         20090513__issue15093__2.diff.txt uploaded by tilghman (license
14)
   Tested by: tzafrir
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=195357 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-05-18 14:27 svnbot         Checkin                                      
2009-05-18 14:27 svnbot         Note Added: 0104964                          
======================================================================




More information about the asterisk-bugs mailing list