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

Asterisk Bug Tracker noreply at bugs.digium.com
Wed May 13 08:50:54 CDT 2009


The following issue has been ASSIGNED. 
====================================================================== 
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:                     assigned
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:              
====================================================================== 
Date Submitted:             2009-05-13 04:33 CDT
Last Modified:              2009-05-13 08:50 CDT
====================================================================== 
Summary:                    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.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-05-13 08:50 file           Status                   new => assigned     
2009-05-13 08:50 file           Assigned To               => tilghman        
======================================================================




More information about the asterisk-bugs mailing list