/** * Initialize GUID management. */ G_GNUC_COLD void guid_init(void) { dbstore_kv_t kv = { sizeof(guid_t), NULL, sizeof(struct guiddata), 1 + sizeof(struct guiddata) /* Version byte not held in structure */ }; dbstore_packing_t packing = { serialize_guiddata, deserialize_guiddata, NULL }; char rev; /* NUL means stable release */ g_assert(NULL == db_guid); guid_gen_syndrome_table(); rev = product_get_revchar(); gtkg_version_mark = guid_gtkg_encode_version(product_get_major(), product_get_minor(), '\0' == rev); if (GNET_PROPERTY(node_debug)) g_debug("GTKG version mark is 0x%x", gtkg_version_mark); /* * Validate that guid_random_muid() correctly marks GUIDs as being GTKG's. */ { struct guid guid_buf; guid_random_muid(&guid_buf); g_assert(guid_is_gtkg(&guid_buf, NULL, NULL, NULL)); } db_guid = dbstore_open(db_guid_what, settings_gnet_db_dir(), db_guid_base, kv, packing, 1, guid_hash, guid_eq, FALSE); guid_prune_old(); guid_prune_ev = cq_periodic_main_add( GUID_PRUNE_PERIOD, guid_periodic_prune, NULL); guid_sync_ev = cq_periodic_main_add( GUID_SYNC_PERIOD, guid_periodic_sync, NULL); }
/** * Send an UDP ping to the host cache. */ static void uhc_send_ping(void) { g_assert(uhc_connecting); guid_random_muid(&uhc_ctx.muid); if (udp_send_ping(&uhc_ctx.muid, uhc_ctx.addr, uhc_ctx.port, TRUE)) { if (GNET_PROPERTY(bootstrap_debug) || GNET_PROPERTY(log_uhc_pings_tx)) { g_debug("BOOT sent UDP SCP ping #%s to %s:%u", guid_hex_str(&uhc_ctx.muid), uhc_ctx.host, uhc_ctx.port); } /* * Give GUI feedback. */ { char msg[256]; str_bprintf(msg, sizeof msg, _("Sent ping to UDP host cache %s:%u"), uhc_ctx.host, uhc_ctx.port); gcu_statusbar_message(msg); } /* * Arm a timer to see whether we should not try to ping another * host cache if we don't get a timely reply. */ g_assert(uhc_ctx.timeout_ev == NULL); uhc_ctx.timeout_ev = cq_main_insert(UHC_TIMEOUT, uhc_ping_timeout, NULL); } else { g_warning("BOOT failed to send UDP SCP to %s", host_addr_port_to_string(uhc_ctx.addr, uhc_ctx.port)); uhc_try_next(); } }