示例#1
0
guint
Gmain_timeout_add(guint interval
,	GSourceFunc	function
,	gpointer	data)
{
	return Gmain_timeout_add_full(G_PRIORITY_DEFAULT
	,	interval, function, data, NULL);
}
示例#2
0
static void
schedule_rexmit_request(struct node_info* node, seqno_t seq, int delay)    
{
	unsigned long		sourceid;
	struct rexmit_info*	ri;

	if (delay == 0) {
		/* generate some random delay,
		 * 50ms offset to allow for out-of-order arrival
		 * without actually sending the rexmit requests,
		 * which happens more often than one might think. */
		const int a = max_rexmit_delay < 100 ? 0 : 50;
		const int b = max_rexmit_delay;
		delay = cl_rand_from_interval(a,b);
	}
	
	ri = malloc(sizeof(struct rexmit_info));
	if (ri == NULL){
		cl_log(LOG_ERR, "%s: memory allocation failed", __FUNCTION__);
		return;
	}
	
	ri->seq = seq;
	ri->node = node;
	
	sourceid = Gmain_timeout_add_full(G_PRIORITY_HIGH - 1, delay, 
					  send_rexmit_request, ri, NULL);
	G_main_setall_id(sourceid, "retransmit request", config->heartbeat_ms/2, 10);
	
	if (sourceid == 0){
		cl_log(LOG_ERR, "%s: scheduling a timeout event failed", 
		       __FUNCTION__);
		return;
	}

	if (rexmit_hash_table == NULL){
		init_rexmit_hash_table();
	}
	g_hash_table_insert(rexmit_hash_table, (gpointer)ri, (gpointer)sourceid);
	
	return ;
}