* This method will free the old CIB pointer on success and the new one * on failure. */
| 501 | * on failure. |
| 502 | */ |
| 503 | int |
| 504 | activateCibXml(xmlNode * new_cib, gboolean to_disk, const char *op) |
| 505 | { |
| 506 | xmlNode *saved_cib = the_cib; |
| 507 | |
| 508 | CRM_ASSERT(new_cib != saved_cib); |
| 509 | if (initializeCib(new_cib) == FALSE) { |
| 510 | free_xml(new_cib); |
| 511 | crm_err("Ignoring invalid or NULL CIB"); |
| 512 | |
| 513 | if (saved_cib != NULL) { |
| 514 | crm_warn("Reverting to last known CIB"); |
| 515 | if (initializeCib(saved_cib) == FALSE) { |
| 516 | /* oh we are so dead */ |
| 517 | crm_crit("Couldn't re-initialize the old CIB!"); |
| 518 | exit(1); |
| 519 | } |
| 520 | |
| 521 | } else { |
| 522 | crm_crit("Could not write out new CIB and no saved" " version to revert to"); |
| 523 | } |
| 524 | return -ENODATA; |
| 525 | } |
| 526 | |
| 527 | free_xml(saved_cib); |
| 528 | if (cib_writes_enabled && cib_status == pcmk_ok && to_disk) { |
| 529 | crm_debug("Triggering CIB write for %s op", op); |
| 530 | mainloop_set_trigger(cib_writer); |
| 531 | } |
| 532 | |
| 533 | return pcmk_ok; |
| 534 | } |
| 535 | |
| 536 | static void cib_diskwrite_complete(GPid pid, gint status, gpointer user_data) |
| 537 | { |
no test coverage detected