| 575 | } |
| 576 | |
| 577 | gboolean |
| 578 | update_node_processes(uint32_t id, const char *uname, uint32_t procs) |
| 579 | { |
| 580 | gboolean changed = FALSE; |
| 581 | pcmk_peer_t *node = g_hash_table_lookup(peers, GUINT_TO_POINTER(id)); |
| 582 | |
| 583 | if (node == NULL) { |
| 584 | changed = TRUE; |
| 585 | |
| 586 | node = calloc(1, sizeof(pcmk_peer_t)); |
| 587 | node->id = id; |
| 588 | |
| 589 | g_hash_table_insert(peers, GUINT_TO_POINTER(id), node); |
| 590 | node = g_hash_table_lookup(peers, GUINT_TO_POINTER(id)); |
| 591 | CRM_ASSERT(node != NULL); |
| 592 | } |
| 593 | |
| 594 | if (uname != NULL) { |
| 595 | if (node->uname == NULL || safe_str_eq(node->uname, uname) == FALSE) { |
| 596 | int lpc, len = strlen(uname); |
| 597 | |
| 598 | crm_notice("%p Node %u now known as %s%s%s", node, id, uname, |
| 599 | node->uname?node->uname:", was: ", node->uname?node->uname:""); |
| 600 | free(node->uname); |
| 601 | node->uname = strdup(uname); |
| 602 | changed = TRUE; |
| 603 | |
| 604 | for(lpc = 0; lpc < len; lpc++) { |
| 605 | if(uname[lpc] >= 'A' && uname[lpc] <= 'Z') { |
| 606 | crm_warn("Node names with capitals are discouraged, consider changing '%s' to something else", uname); |
| 607 | break; |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | } else { |
| 613 | crm_trace("Empty uname for node %u", id); |
| 614 | } |
| 615 | |
| 616 | if (procs != 0) { |
| 617 | if(procs != node->processes) { |
| 618 | crm_debug("Node %s now has process list: %.32x (was %.32x)", |
| 619 | node->uname, procs, node->processes); |
| 620 | node->processes = procs; |
| 621 | changed = TRUE; |
| 622 | |
| 623 | } else { |
| 624 | crm_trace("Node %s still has process list: %.32x", node->uname, procs); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | if (changed && id == local_nodeid) { |
| 629 | update_process_clients(); |
| 630 | update_process_peers(); |
| 631 | } |
| 632 | return changed; |
| 633 | } |
| 634 |
no test coverage detected