eapol/eapol_framework/eapol_common/am/common/eap_timer_queue.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: %
    19 * %version: 14.1.2 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
   421 eap_timer_queue_c::~eap_timer_queue_c()
   421 eap_timer_queue_c::~eap_timer_queue_c()
   422 {
   422 {
   423 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   423 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   424 
   424 
   425 	deactivate_timer_queue();
   425 	deactivate_timer_queue();
   426 
       
   427 	trace_timer();
       
   428 
       
   429 	EAP_TRACE_TIMER(
       
   430 		m_am_tools,
       
   431 		TRACE_FLAGS_TIMER_QUEUE,
       
   432 		(EAPL("TIMER: eap_timer_queue_c::~eap_timer_queue_c(): m_timer_queue=0x%08x, m_new_event_begin=0x%08x, m_new_event_end=0x%08x\n"),
       
   433 		m_timer_queue,
       
   434 		m_new_event_begin,
       
   435 		m_new_event_end));
       
   436 
   426 
   437 	// cancel_all_timers() must be called before destructor.
   427 	// cancel_all_timers() must be called before destructor.
   438 	EAP_ASSERT_TOOLS(m_am_tools, m_timer_queue == 0);
   428 	EAP_ASSERT_TOOLS(m_am_tools, m_timer_queue == 0);
   439 	EAP_ASSERT_TOOLS(m_am_tools, m_new_event_begin == 0);
   429 	EAP_ASSERT_TOOLS(m_am_tools, m_new_event_begin == 0);
   440 	EAP_ASSERT_TOOLS(m_am_tools, m_new_event_end == 0);
   430 	EAP_ASSERT_TOOLS(m_am_tools, m_new_event_end == 0);
   697 					}
   687 					}
   698 				}
   688 				}
   699 
   689 
   700 				if (current != 0)
   690 				if (current != 0)
   701 				{
   691 				{
   702 					EAP_TRACE_DEBUG(
   692 					EAP_TRACE_TIMER(
   703 						m_am_tools,
   693 						m_am_tools,
   704 						TRACE_FLAGS_DEFAULT,
   694 						TRACE_FLAGS_DEFAULT,
   705 						(EAPL("TIMER: eap_timer_queue_c::timer_expired(): [0x%08x]->initializer(0x%08x)->timer_expired(")
   695 						(EAPL("TIMER: timer_expired(): [0x%08x]->initializer(0x%08x)->timer_expired(")
   706 						 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
   696 						 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
   707 						 current,
   697 						 current,
   708 						 current->get_initializer(),
   698 						 current->get_initializer(),
   709 						 current->get_id(),
   699 						 current->get_id(),
   710 						 current->get_data(),
   700 						 current->get_data(),
  1278 		 event->get_id(),
  1268 		 event->get_id(),
  1279 		 event->get_data(),
  1269 		 event->get_data(),
  1280 		 event->get_time_ms()));
  1270 		 event->get_time_ms()));
  1281 
  1271 
  1282 	// Adds the new event to the end of the list to keep the order of events correct.
  1272 	// Adds the new event to the end of the list to keep the order of events correct.
  1283 	EAP_ASSERT((m_new_event_begin == 0
  1273 	EAP_ASSERT(m_new_event_begin == 0
  1284 				&& m_new_event_end == 0)
  1274 		&& m_new_event_end == 0
  1285 			   || (m_new_event_begin != 0
  1275 		|| m_new_event_begin != 0
  1286 				   && m_new_event_end != 0));
  1276 		&& m_new_event_end != 0);
  1287 
  1277 
  1288 	if (m_new_event_begin == 0
  1278 	if (m_new_event_begin == 0
  1289 		&& m_new_event_end == 0)
  1279 		&& m_new_event_end == 0)
  1290 	{
  1280 	{
  1291 		// Adds to the begin.
  1281 		// Adds to the begin.
  1351 
  1341 
  1352 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1342 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1353 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  1343 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  1354 	}
  1344 	}
  1355 
  1345 
  1356 	EAP_TRACE_DEBUG(
       
  1357 		m_am_tools,
       
  1358 		TRACE_FLAGS_DEFAULT,
       
  1359 		(EAPL("TIMER: eap_timer_queue_c::set_timer(): [0x%08x]->initializer(0x%08x)->set_timer(")
       
  1360 		 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
       
  1361 		 event,
       
  1362 		 event->get_initializer(),
       
  1363 		 event->get_id(),
       
  1364 		 event->get_data(),
       
  1365 		 event->get_original_time()));
       
  1366 
  1346 
  1367 	if (m_use_eap_millisecond_timer == true)
  1347 	if (m_use_eap_millisecond_timer == true)
  1368 	{
  1348 	{
  1369 		// The next pulse_timer() function call will add the event to timer queue.
  1349 		// The next pulse_timer() function call will add the event to timer queue.
  1370 		eap_status_e status = add_new_pending_timer(event);
  1350 		eap_status_e status = add_new_pending_timer(event);
  1455 
  1435 
  1456 			if (remove == m_new_event_end)
  1436 			if (remove == m_new_event_end)
  1457 			{
  1437 			{
  1458 				m_new_event_end = previous;
  1438 				m_new_event_end = previous;
  1459 			}
  1439 			}
  1460 
       
  1461 			EAP_TRACE_DEBUG(
       
  1462 				m_am_tools,
       
  1463 				TRACE_FLAGS_DEFAULT,
       
  1464 				(EAPL("TIMER: eap_timer_queue_c::cancel_pending_timer(): [0x%08x]->initializer(0x%08x)->cancel_pending_timer(")
       
  1465 				 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
       
  1466 				 remove,
       
  1467 				 remove->get_initializer(),
       
  1468 				 remove->get_id(),
       
  1469 				 remove->get_data(),
       
  1470 				 remove->get_original_time()));
       
  1471 
  1440 
  1472 			remove->set_next(0);
  1441 			remove->set_next(0);
  1473 			delete remove;
  1442 			delete remove;
  1474 
  1443 
  1475 			if (previous != 0)
  1444 			if (previous != 0)
  1534 	{
  1503 	{
  1535 		eap_timer_queue_event_c * cursor = get_hashed_timer_event(initializer, id);
  1504 		eap_timer_queue_event_c * cursor = get_hashed_timer_event(initializer, id);
  1536 
  1505 
  1537 		while(cursor != 0)
  1506 		while(cursor != 0)
  1538 		{
  1507 		{
  1539 			EAP_TRACE_DEBUG(
  1508 			EAP_TRACE_TIMER(
  1540 				m_am_tools,
  1509 				m_am_tools,
  1541 				TRACE_FLAGS_DEFAULT,
  1510 				TRACE_FLAGS_TIMER,
  1542 				(EAPL("TIMER: eap_timer_queue_c::cancel_timer(): [0x%08x]->initializer(0x%08x)->cancel_timer(")
  1511 				(EAPL("TIMER: [0x%08x] cancel_timer(initializer 0x%08x, ")
  1543 				 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
  1512 				 EAPL("id 0x%02x, original time %8d)\n"),
  1544 				 cursor,
  1513 				 cursor,
  1545 				 cursor->get_initializer(),
  1514 				 initializer,
  1546 				 cursor->get_id(),
  1515 				 id,
  1547 				 cursor->get_data(),
       
  1548 				 cursor->get_original_time()));
  1516 				 cursor->get_original_time()));
  1549 
  1517 
  1550 			if (cursor == m_timer_queue)
  1518 			if (cursor == m_timer_queue)
  1551 			{
  1519 			{
  1552 				// The first event will be removed.
  1520 				// The first event will be removed.
  1707 			// The first event will be removed.
  1675 			// The first event will be removed.
  1708 			m_timer_queue = m_timer_queue->get_next();
  1676 			m_timer_queue = m_timer_queue->get_next();
  1709 
  1677 
  1710 			while (cursor != 0)
  1678 			while (cursor != 0)
  1711 			{
  1679 			{
  1712 				EAP_TRACE_DEBUG(
  1680 				EAP_TRACE_TIMER(
  1713 					m_am_tools,
  1681 					m_am_tools,
  1714 					TRACE_FLAGS_DEFAULT,
  1682 					TRACE_FLAGS_TIMER,
  1715 					(EAPL("TIMER: eap_timer_queue_c::cancel_all_timers(): [0x%08x]->initializer(0x%08x)->cancel_all_timers(")
  1683 					(EAPL("TIMER: [0x%08x] cancel_all_timers()\n"),
  1716 					 EAPL("id 0x%02x, data 0x%08x, original time %8d)\n"),
  1684 					cursor));
  1717 					 cursor,
       
  1718 					 cursor->get_initializer(),
       
  1719 					 cursor->get_id(),
       
  1720 					 cursor->get_data(),
       
  1721 					 cursor->get_original_time()));
       
  1722 
  1685 
  1723 				eap_timer_queue_event_c *next = cursor->get_next_same_time();
  1686 				eap_timer_queue_event_c *next = cursor->get_next_same_time();
  1724 
  1687 
  1725 				cursor->set_prev(0);
  1688 				cursor->set_prev(0);
  1726 				cursor->set_next(0);
  1689 				cursor->set_next(0);