Changeset 23530 for trunk/Ohana/src/opihi/pantasks/ControllerOps.c
- Timestamp:
- Mar 25, 2009, 11:56:09 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pantasks/ControllerOps.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r20032 r23530 12 12 13 13 /* local static variables to track the controller host properties */ 14 /* these are used by AddHost and DeleteHost, and are only called by controller_host.c (clientThread) */ 15 /* or by RestartController : lock between these two? */ 14 16 static Host *hosts = NULL; 15 17 static int Nhosts = 0; … … 31 33 } 32 34 35 // XXX possible race condition problem: if we delete a host while the controller 36 // is being restarted. to fix this, we need to keep the deletion in controller_thread, 37 // but perhaps mark it in the client_thread? 33 38 int DeleteHost (char *hostname) { 34 39 … … 261 266 } 262 267 268 // This function is called by the JobTaskThread via SubmitJob. We need to unlock the 269 // JobTaskLock to avoid a dead lock with the JobTaskLock called in CheckController 270 JobTaskUnlock(); 271 ControlLock(__func__); 263 272 InitIOBuffer (&buffer, 0x100); 264 273 status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer); 265 274 free (cmd); 275 ControlUnlock(__func__); 276 JobTaskLock(); 277 266 278 267 279 /* extract the job PID from the controller response */ … … 411 423 if ((status == -1) && (errno == EPIPE)) { 412 424 StopController (); 413 gprint (GP_ERR, "controller is down (pipe closed), restarting\n");425 fprintf (stderr, "controller is down (pipe closed), restarting\n"); 414 426 if (!RestartController ()) { 415 427 return (FALSE); … … 434 446 if (status == 0) { 435 447 StopController (); 436 gprint (GP_ERR, "controller is down (EOF), restarting\n");448 fprintf (stderr, "controller is down (EOF), restarting\n"); 437 449 if (!RestartController ()) { 438 450 return (FALSE); … … 441 453 } 442 454 if (status == -1) { 443 gprint (GP_ERR, "controller is not responding (%d tries)\n", j);455 fprintf (stderr, "controller is not responding (%d tries)\n", j); 444 456 gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR); 445 457 } 446 458 } 447 459 if (status == -1) { 448 gprint (GP_ERR, "controller still not responding, giving up\n");460 fprintf (stderr, "controller still not responding, giving up\n"); 449 461 return (FALSE); 450 462 } … … 456 468 bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer); 457 469 } 458 /* if (VerboseMode()) gprint (GP_ERR, "message received, %d cycles\n", i); */470 if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i); 459 471 return (TRUE); 460 472 } … … 492 504 } 493 505 506 void PrintControllerBusyJobs () { 507 508 int status; 509 char command[1024]; 510 IOBuffer buffer; 511 512 /* check if controller is running */ 513 status = CheckControllerStatus (); 514 if (!status) { 515 return; 516 } 517 518 sprintf (command, "jobstack busy"); 519 InitIOBuffer (&buffer, 0x100); 520 521 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 522 523 if (status) { 524 gprint (GP_LOG, " jobs currently running remotely:\n"); 525 gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); 526 } else { 527 gprint (GP_LOG, "controller is not responding\n"); 528 } 529 FreeIOBuffer (&buffer); 530 return; 531 } 532 494 533 int PrintControllerOutput () { 495 534 … … 581 620 InitIOBuffer (&buffer, 0x100); 582 621 583 // XXX lock the host table? SerialThreadLock ();622 // XXX lock the host table? no: that would risk a dead lock between client and controller threads: 584 623 gprint (GP_ERR, "pcontrol restarted, reloading hosts\n"); 585 624 for (i = 0; i < Nhosts; i++) { … … 588 627 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 589 628 } 590 // SerialThreadUnlock ();591 629 592 630 if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);
Note:
See TracChangeset
for help on using the changeset viewer.
