Ejemplo n.º 1
0
/**
 * Pass 1 handler on each tree node leave.
 */
static void
xfmt_handle_pass1_leave(void *node, void *data)
{
    xnode_t *xn = node;
    struct xfmt_pass1 *xp1 = data;

    g_assert(uint_is_positive(xp1->depth));
    (void) xn;

    xp1->depth--;
}
Ejemplo n.º 2
0
/**
 * Free NAT-PMP RPC descriptor.
 */
static void
natpmp_rpc_free(struct natpmp_rpc *rd)
{
	natpmp_rpc_check(rd);

	g_assert(uint_is_positive(natpmp_rpc_pending));

	natpmp_rpc_pending--;

	pmsg_free_null(&rd->mb);
	rd->magic = 0;
	WFREE(rd);
}
Ejemplo n.º 3
0
/**
 * Leaving scope.
 */
static inline void
xfmt_pass2_leaving(struct xfmt_pass2 *xp2)
{
    g_assert(uint_is_positive(xp2->depth));

    /*
     * Need to clear the prefixes table first: see xfmt_ns_declare().
     */

    symtab_leave(xp2->prefixes, xp2->depth);
    symtab_leave(xp2->uris, xp2->depth);

    xp2->depth--;
}
Ejemplo n.º 4
0
/**
 * Computes republish delay for a value.
 *
 * @param info			the information from the publishing layer
 * @param expiration	expected value expiration time
 *
 * @return republishing delay, in seconds.
 *
 * @attention
 * As a side effect, increases the count of satisfactory publishes if the
 * information from the publishing layer lead us to believe it is.  Therefore
 * this routine is not idempotent and should be called only once per callback.
 */
int
publisher_delay(const pdht_info_t *info, time_delta_t expiration)
{
	int delay;

	if (0 == info->all_roots) {
		delay = PUBLISH_SAFETY;
	} else if (
		info->all_roots >= KDA_K ||
		info->presence >= PUBLISH_MIN_PROBABILITY
	) {
		delay = expiration - PUBLISH_SAFETY;
		gnet_stats_inc_general(GNR_DHT_PUBLISHING_SATISFACTORY);
	} else {
		g_assert(uint_is_positive(info->all_roots));
		delay =
			inverse_decimation[info->all_roots - 1] * expiration;
		delay -= PUBLISH_SAFETY;
		delay = MAX(delay, PUBLISH_SAFETY);
	}

	return delay;
}