Example #1
0
/// Establishes keepalive (periodic ping) on the connection.
///
/// @return the keepalive timer id, or INVALID_TIMER
/// @private
static int Sql_P_Keepalive(Sql* self)
{
	uint32 timeout, ping_interval;

	// set a default value first
	timeout = 28800; // 8 hours

	// request the timeout value from the mysql server
	Sql_GetTimeout(self, &timeout);

	if( timeout < 60 )
		timeout = 60;

	// establish keepalive
	ping_interval = timeout - 30; // 30-second reserve
	//add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer");
	return add_timer_interval(gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000);
}
Example #2
0
int32 Sql_Keepalive(Sql_t* self)
{
	uint32 timeout, ping_interval;

	// set a default value first
	timeout = 28800; // 8 hours

	// request the timeout value from the mysql server
	Sql_GetTimeout(self, &timeout);

	if( timeout < 60 )
	{
		timeout = 60;
	}
	// establish keepalive
	ping_interval = timeout - 30; // 30-second reserve
	CTaskMgr::getInstance()->AddTask("Sql_P_KeepAliveTimer",gettick()+ping_interval*1000,self,CTaskMgr::TASK_INTERVAL,Sql_P_KeepaliveTimer,ping_interval*1000);
	return 0;
}