Ejemplo n.º 1
0
/**
 * Generate a new random (modern) message ID for pings.
 */
void
guid_ping_muid(struct guid *muid)
{
	guid_random_fill(muid);
	guid_flag_modern(muid);
	guid_flag_gtkg(muid);		/* Mark as being from GTKG */
}
Ejemplo n.º 2
0
/**
 * Generate a new GUID atom that is not already conflicting with any other
 * GUID recorded in the supplied hikset (hash set with values pointing to
 * the GUID key).
 *
 * @attention
 * It is up to the caller to later insert the value referencing this GUID in
 * the hikset to prevent further duplicates.  To avoid race conditions between
 * the checking of the hiset and the insertion, the hikset should be locked
 * if it is shared by multiple threads.
 *
 * @param hik		the hikset against which we need to check for duplicates
 * @param gtkg		whether to flag the GUID as being generated by GTKG.
 *
 * @return a new unique GUID atom.
 */
const guid_t *
guid_unique_atom(const hikset_t *hik, bool gtkg)
{
	int i;
	guid_t guid;

	entropy_harvest_time();

	for (i = 0; i < 100; i++) {
		guid_random_fill(&guid);
		if (gtkg)
			guid_flag_gtkg(&guid);	/* Mark as being from GTKG */

		if (NULL == hikset_lookup(hik, &guid))
			return atom_guid_get(&guid);
	}

	g_error("%s(): no luck with random number generator", G_STRFUNC);
}
Ejemplo n.º 3
0
/**
 * Generate a new random GUID, flagged as GTKG.
 */
void
guid_random_muid(guid_t *muid)
{
	guid_random_fill(muid);
	guid_flag_gtkg(muid);		/* Mark as being from GTKG */
}