Git Product home page Git Product logo

Comments (20)

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Can you try the current 1.1 CVS? I think this is a duplicate of STR #47 which I just commited a fix for...

Thanks!

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Tried and unable to recreate loss of printers. I expect this was the same as #47, however I am still getting the User Signal 1
cups: unable to start scheduler
message.
Where is this coming from as the scheduler does start.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

The parent process waits for SIGUSR1 from the child, and it sounds like Solaris isn't using our signal handler.

Can you use truss on the cupsd process and attach the output to the STR? Thanks!

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

I tried truss but could never get it to happed when trussed. It does't always happen anyway. Perhaps it is timing related. I'll try again.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Please let me know if you can reproduce it.

I'll be releasing 1.1.19rc3 shortly.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Never fails when trussed. I've just noticed rc3 is available. Will try again with rc3 but will probably be Friday before I get a chance.

Thanks

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

OK, please let me know before May 12th... (cutoff date for STRs on rc3...)

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Hi,
Still happening in rc3.

Had a chance to try a few things out and have come to the conclusion that, on occasion, the child may be signaling before the parent has set up the signal handler. The sigset in the parent is after the fork.

This would explain why it does not always happen and that it never happens under truss which slows things down.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

The signal handler registration stuff is a likely culprit, although I would expect the parent to get control back before the child has a chance to finish processing, even on a fast machine.

I'm reclassifying this as priority 2 (low) since it doesn't prevent the software from working, but we'll move the signal handler setup before the fork() for the final 1.1.19 release (or next release candidate, if required).

If you get a chance, please try the patch I'm attaching to this STR (or CVS) and let me know if the problem goes away.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Something more fundamental is wrong I'm afraid.

I added the change and now get the situation where the parent is hanging. I put some debug in and found that the parent was catching the SIGUSR1 but then still waiting. It needed a kill -16 to cause it to catch it again then exit. Could it have caught the first signal prior to the wait ? Does it need the sigusr1_handler to exit the process ?

Also, if you leave the sigset before the fork, do the signals need to be reset in the child ?

( btw cpu is Blade 100 with ultrasparc-IIe 502mHZ )

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Really wish I could reproduce your problem on our systems here.

The sigset's are harmless for the child, as those get reset after the fork. The signal should be interrupting the sleep() function, unless Sun is incorrectly applying POSIX signal options (dunno if sigset is emulated on your version of Solaris or not)

Does it work if you comment the HAVE_SIGSET define in config.h out?

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

I really wish I couldn't :-).

I think it best to revert to the pre patch situation as this does exit on receipt of the SIGUSR1. This may be a stupid question, but as the default action on receipt of SIGUSR1 is exit, why do we need a signal handler function ?

It will be Friday again before I can spend any more time on this so don't let me delay anything.

( It was a public holiday in the UK yesterday, hence no response before today. )

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Without the signal handler, you'll get a non-zero exit status which will cause the startup script to think that startup was unsuccessful...

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Removing HAVE_SIGSET has no impact. Still fails on occasion.
I have put debug in and parent is definitly catching he sigusr1 before the wait.
The only way I can get it to work consistently is to set a global variable in the sigusr1_handler and test it prior to the wait, exiting if it is set.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Forgot to mention. I used the patched main.c, otherwise signal can arrive before sigset.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Steve,

Try the attached patch against the unpatched 1.1.19rc2 or current CVS - I changed the code to register a signal handler for SIGCHLD as well as SIGUSR1 and to store the signal that is delivered to the parent. The parent sleeps until it gets one of the signals, and then only gets the child status if needed.

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: steve.p.walsh.hp

Unable to reproduce with new patch.
Problem is fixed.
Many Thanks

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

CUPS.org User: mike

Great!

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

"cupsd-signal.patch":

Index: main.c

RCS file: /development/cvs/cups/scheduler/main.c,v
retrieving revision 1.102
diff -u -r1.102 main.c
--- main.c 2003/05/01 17:58:28 1.102
+++ main.c 2003/05/02 15:51:00
@@ -171,33 +171,37 @@

if (!fg)
{

  • if (fork() > 0)
  • {
  • /*
    
  •  \* OK, wait for the child to startup and send us SIGUSR1...  We
    
  •  \* also need to ignore SIGHUP which might be sent by the init
    
  •  \* script to restart the scheduler...
    
  •  */
    
  • /*
  • * Setup signal handlers for the parent...
  • */

#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */

  •  sigset(SIGUSR1, sigusr1_handler);
    
  • sigset(SIGUSR1, sigusr1_handler);
  •  sigset(SIGHUP, SIG_IGN);
    
  • sigset(SIGHUP, SIG_IGN);
    #elif defined(HAVE_SIGACTION)
  •  memset(&action, 0, sizeof(action));
    
  •  sigemptyset(&action.sa_mask);
    
  •  sigaddset(&action.sa_mask, SIGUSR1);
    
  •  action.sa_handler = sigusr1_handler;
    
  •  sigaction(SIGUSR1, &action, NULL);
    
  • memset(&action, 0, sizeof(action));
  • sigemptyset(&action.sa_mask);
  • sigaddset(&action.sa_mask, SIGUSR1);
  • action.sa_handler = sigusr1_handler;
  • sigaction(SIGUSR1, &action, NULL);
  •  sigemptyset(&action.sa_mask);
    
  •  action.sa_handler = SIG_IGN;
    
  •  sigaction(SIGHUP, &action, NULL);
    
  • sigemptyset(&action.sa_mask);
  • action.sa_handler = SIG_IGN;
  • sigaction(SIGHUP, &action, NULL);
    #else
  •  signal(SIGUSR1, sigusr1_handler);
    
  • signal(SIGUSR1, sigusr1_handler);
  •  signal(SIGHUP, SIG_IGN);
    
  • signal(SIGHUP, SIG_IGN);
    #endif /* HAVE_SIGSET */
  • if (fork() > 0)

  • {

  • /*
    
  •  \* OK, wait for the child to startup and send us SIGUSR1...  We
    
  •  \* also need to ignore SIGHUP which might be sent by the init
    
  •  \* script to restart the scheduler...
    
  •  */
    

    if (wait(&i) < 0)
    i = 0;

from cups.

michaelrsweet avatar michaelrsweet commented on July 17, 2024

"cupsd-signal-v2.patch":

Index: main.c

RCS file: /development/cvs/cups/scheduler/main.c,v
retrieving revision 1.100
retrieving revision 1.104
diff -u -r1.100 -r1.104
--- main.c 2003/04/10 20:14:06 1.100
+++ main.c 2003/05/09 15:11:13 1.104
@@ -30,6 +30,7 @@

  • ReleaseSignals() - Release signals for delivery.
  • SetString() - Set a string value.
  • SetStringf() - Set a formatted string value.
  • * parent_handler() - Catch USR1/CHLD signals...
  • sigchld_handler() - Handle 'child' signals from old processes.
  • sighup_handler() - Handle 'hangup' signals to reconfigure the scheduler.
  • sigterm_handler() - Handle 'terminate' signals that stop the scheduler.
    @@ -55,10 +56,10 @@
  • Local functions...
    */

+static void parent_handler(int sig);
static void sigchld_handler(int sig);
static void sighup_handler(int sig);
static void sigterm_handler(int sig);
-static void sigusr1_handler(int sig);
static void usage(void);

@@ -66,6 +67,7 @@

  • Local globals...
    */

+static int parent_signal = 0; /* Set to signal number from child /
static int holdcount = 0; /
Number of time "hold" was called /
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
static sigset_t holdmask; /
Old POSIX signal mask */
@@ -170,41 +172,53 @@

if (!fg)
{

  • if (fork() > 0)
  • {
  • /*
    
  •  \* OK, wait for the child to startup and send us SIGUSR1...  We
    
  •  \* also need to ignore SIGHUP which might be sent by the init
    
  •  \* script to restart the scheduler...
    
  •  */
    
  • /*
  • * Setup signal handlers for the parent...
  • */

#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */

  •  sigset(SIGUSR1, sigusr1_handler);
    
  • sigset(SIGUSR1, parent_handler);
  • sigset(SIGCHLD, parent_handler);
  •  sigset(SIGHUP, SIG_IGN);
    
  • sigset(SIGHUP, SIG_IGN);
    #elif defined(HAVE_SIGACTION)
  •  memset(&action, 0, sizeof(action));
    
  •  sigemptyset(&action.sa_mask);
    
  •  sigaddset(&action.sa_mask, SIGUSR1);
    
  •  action.sa_handler = sigusr1_handler;
    

- sigaction(SIGUSR1, &action, NULL);

  •  sigemptyset(&action.sa_mask);
    
  •  action.sa_handler = SIG_IGN;
    
  •  sigaction(SIGHUP, &action, NULL);
    
  • memset(&action, 0, sizeof(action));
  • sigemptyset(&action.sa_mask);
  • sigaddset(&action.sa_mask, SIGUSR1);
  • action.sa_handler = parent_handler;
  • sigaction(SIGUSR1, &action, NULL);
  • sigaction(SIGCHLD, &action, NULL);
  • sigemptyset(&action.sa_mask);

  • action.sa_handler = SIG_IGN;

  • sigaction(SIGHUP, &action, NULL);
    #else

  •  signal(SIGUSR1, sigusr1_handler);
    
  • signal(SIGUSR1, parent_handler);

  • signal(SIGCLD, parent_handler);

  •  signal(SIGHUP, SIG_IGN);
    
  • signal(SIGHUP, SIG_IGN);
    #endif /* HAVE_SIGSET */

  •  if (wait(&i) < 0)
    
  •    i = 0;
    
  • if (fork() > 0)

  • {

  • /*
    
  •  \* OK, wait for the child to startup and send us SIGUSR1 or to crash
    
  •  \* and the OS send us SIGCHLD...  We also need to ignore SIGHUP which
    
  •  \* might be sent by the init script to restart the scheduler...
    
  •  */
    
  •  for (; parent_signal == 0;)
    
  •    sleep(1);
    
  •  if (i == 0)
    
  •  if (parent_signal == SIGUSR1)
     return (0);
    
  •  if (i >= 256)
    
  •  if (wait(&i) < 0)
    
  •  {
    
  •    perror("cupsd");
    
  • i = 1;

  •  }
    
  •  else if (i >= 256)
     fprintf(stderr, "cupsd: Child exited with status %d!\n", i / 256);
    

    else
    fprintf(stderr, "cupsd: Child exited on signal %d!\n", i);
    @@ -289,6 +303,17 @@
    }

    /*

  • * Read configuration...

  • */

  • if (!ReadConfiguration())
  • {
  • syslog(LOG_LPR, "Unable to read configuration file '%s' - exiting!",
  •       ConfigurationFile);
    
  • return (1);
  • }
  • /*
    • Catch hangup and child signals and ignore broken pipes...
      */

@@ -332,17 +357,6 @@
signal(SIGTERM, sigterm_handler);
#endif /* HAVE_SIGSET */

  • /*
  • * Read configuration...

- */

  • if (!ReadConfiguration())
  • {
  • syslog(LOG_LPR, "Unable to read configuration file '%s' - exiting!",
  •       ConfigurationFile);
    
  • return (1);

- }

#ifdef __sgi
/*

  • Try to create a fake lpsched lock file if one is not already there.
    @@ -861,6 +875,21 @@

    /*

    • * 'parent_handler()' - Catch USR1/CHLD signals...
    • /
      +
      +static void
      +parent_handler(int sig) /
      I - Signal */
      +{
    • /*
    • * Store the signal we got from the OS and return...
    • */
    • parent_signal = sig;
      +}

    +/*

    • 'sigchld_handler()' - Handle 'child' signals from old processes.
      */

@@ -1038,17 +1067,6 @@

/*

  • * 'sigusr1_handler()' - Catch USR1 signals...

- */

-static void
-sigusr1_handler(int sig) /* I - Signal */
-{

  • (void)sig; /* remove compiler warnings... _/
    -}

-/_

  • 'usage()' - Show scheduler usage.
    */

from cups.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.