MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / attrd_local_callback

Function attrd_local_callback

tools/attrd.c:778–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778void
779attrd_local_callback(xmlNode * msg)
780{
781 static int plus_plus_len = 5;
782 attr_hash_entry_t *hash_entry = NULL;
783 const char *from = crm_element_value(msg, F_ORIG);
784 const char *op = crm_element_value(msg, F_ATTRD_TASK);
785 const char *attr = crm_element_value(msg, F_ATTRD_ATTRIBUTE);
786 const char *value = crm_element_value(msg, F_ATTRD_VALUE);
787 const char *host = crm_element_value(msg, F_ATTRD_HOST);
788
789 if (safe_str_eq(op, "refresh")) {
790 crm_notice("Sending full refresh (origin=%s)", from);
791 g_hash_table_foreach(attr_hash, update_for_hash_entry, NULL);
792 return;
793 }
794
795 if (host != NULL && safe_str_neq(host, attrd_uname)) {
796 send_cluster_message(crm_get_peer(0, host), crm_msg_attrd, msg, FALSE);
797 return;
798 }
799
800 crm_debug("%s message from %s: %s=%s", op, from, attr, crm_str(value));
801 hash_entry = find_hash_entry(msg);
802 if (hash_entry == NULL) {
803 return;
804 }
805
806 if (hash_entry->uuid == NULL) {
807 const char *key = crm_element_value(msg, F_ATTRD_KEY);
808
809 if (key) {
810 hash_entry->uuid = strdup(key);
811 }
812 }
813
814 crm_debug("Supplied: %s, Current: %s, Stored: %s",
815 value, hash_entry->value, hash_entry->stored_value);
816
817 if (safe_str_eq(value, hash_entry->value)
818 && safe_str_eq(value, hash_entry->stored_value)) {
819 crm_trace("Ignoring non-change");
820 return;
821
822 } else if (value) {
823 int offset = 1;
824 int int_value = 0;
825 int value_len = strlen(value);
826
827 if (value_len < (plus_plus_len + 2)
828 || value[plus_plus_len] != '+'
829 || (value[plus_plus_len + 1] != '+' && value[plus_plus_len + 1] != '=')) {
830 goto set_unexpanded;
831 }
832
833 int_value = char2score(hash_entry->value);
834 if (value[plus_plus_len + 1] != '+') {
835 const char *offset_s = value + (plus_plus_len + 2);

Callers 3

attrd_ipc_dispatchFunction · 0.85
attrd_ha_callbackFunction · 0.85
attrd_ais_dispatchFunction · 0.85

Calls 9

crm_element_valueFunction · 0.85
safe_str_neqFunction · 0.85
send_cluster_messageFunction · 0.85
crm_get_peerFunction · 0.85
find_hash_entryFunction · 0.85
char2scoreFunction · 0.85
crm_xml_add_intFunction · 0.85
stop_attrd_timerFunction · 0.85
attrd_trigger_updateFunction · 0.85

Tested by

no test coverage detected