IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20032


Ignore:
Timestamp:
Oct 9, 2008, 2:18:56 PM (18 years ago)
Author:
eugene
Message:

remember to restart pcontrol on crashes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r19125 r20032  
    159159  return (TRUE);
    160160
    161   escape:
     161escape:
    162162  gprint (GP_ERR, "garbage in pcontrol reponse\n");
    163163  FreeIOBuffer (&buffer);
     
    411411  if ((status == -1) && (errno == EPIPE)) {
    412412    StopController ();
    413     gprint (GP_ERR, "controller is down, restarting\n");
     413    gprint (GP_ERR, "controller is down (pipe closed), restarting\n");
    414414    if (!RestartController ()) {
    415415      return (FALSE);
     
    420420  /* for commands which don't return a prompt, don't look for one */
    421421  if (response == NULL) {
    422       return (TRUE);
     422    return (TRUE);
    423423  }
    424424
     
    427427  status = -1;
    428428  for (j = 0; (status == -1) && (j < 10); j++) {
    429       for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
    430           status = ReadtoIOBuffer (buffer, stdout_cntl);
    431           line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
    432           if (status == -1) nanosleep (&request, &remain);
     429    for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
     430      status = ReadtoIOBuffer (buffer, stdout_cntl);
     431      line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
     432      if (status == -1) nanosleep (&request, &remain);
     433    }
     434    if (status ==  0) {
     435      StopController ();
     436      gprint (GP_ERR, "controller is down (EOF), restarting\n");
     437      if (!RestartController ()) {
     438        return (FALSE);
    433439      }
    434       if (status ==  0) {
    435           StopController ();
    436           gprint (GP_ERR, "controller is down\n");
    437           return (FALSE);
    438       }
    439       if (status == -1) {
    440           gprint (GP_ERR, "controller is not responding (%d tries)\n", j);
    441           gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR);
    442       }
     440      return (FALSE);
     441    }
     442    if (status == -1) {
     443      gprint (GP_ERR, "controller is not responding (%d tries)\n", j);
     444      gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR);
     445    }
    443446  }
    444447  if (status == -1) {
    445       gprint (GP_ERR, "controller still not responding, giving up\n");
    446       return (FALSE);
     448    gprint (GP_ERR, "controller still not responding, giving up\n");
     449    return (FALSE);
    447450  }
    448451
     
    570573  IOBuffer buffer;
    571574
    572   gprint (GP_ERR, "controller is down, restarting\n");
     575  gprint (GP_ERR, "attempting to restart pcontrol\n");
    573576  if (!StartController ()) {
    574577    gprint (GP_ERR, "failure to re-start pcontrol\n");
     
    579582
    580583  // XXX lock the host table? SerialThreadLock ();
    581   fprintf (stderr, "controller is down, restarting\n");
     584  gprint (GP_ERR, "pcontrol restarted, reloading hosts\n");
    582585  for (i = 0; i < Nhosts; i++) {
    583     fprintf (stderr, "controller host add %s -threads %d\n", hosts[i].hostname, hosts[i].max_threads);
    584586    snprintf (command, 256, "host add %s -threads %d\n", hosts[i].hostname, hosts[i].max_threads);
     587    gprint (GP_ERR, "sending: %s\n", command);
    585588    status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    586589  }
Note: See TracChangeset for help on using the changeset viewer.