Ejemplo n.º 1
0
void TestListLog(const OS_List* list_p)
{
OS_ListItem* item_l_p;

    if (OS_NULL == list_p) { return; }
    // Trace the results.
    OS_TRACE(D_DEBUG, "\n", OS_NULL);
    item_l_p = OS_LIST_ITEM_NEXT_GET((OS_ListItem*)&OS_LIST_ITEM_LAST_GET(list_p));
    while (OS_DELAY_MAX != OS_LIST_ITEM_VALUE_GET(item_l_p)) {
        OS_TRACE(D_DEBUG, "%d ", (int)OS_LIST_ITEM_VALUE_GET(item_l_p));
        item_l_p = OS_LIST_ITEM_NEXT_GET(item_l_p);
    }
}
Ejemplo n.º 2
0
ACE_INLINE pid_t
OS::wait (int *status)
{
  OS_TRACE ("OS::wait");
#if defined (ACE_LACKS_WAIT)
  ACE_UNUSED_ARG (status);
  ACE_NOTSUP_RETURN (0);
#else
  OSCALL_RETURN (::wait (status), pid_t, -1);
#endif /* ACE_LACKS_WAIT */
}
Ejemplo n.º 3
0
ACE_INLINE pid_t
OS::wait (pid_t pid,
              ACE_exitcode *status,
              int wait_options,
              ACE_HANDLE handle)
{
  OS_TRACE ("OS::wait");
  return OS::waitpid (pid,
                          status,
                          wait_options,
                          handle);
}
Ejemplo n.º 4
0
void TestList(void)
{
OS_List os_test_list;
OS_ListItem* item_l_p;
OS_ListItem* item_next_p;
    // Init list.
    srand(rand());
    OS_ListInit(&os_test_list);
    TEST_ASSERT_TRUE(OS_LIST_IS_INITIALISED(&os_test_list));
    // Add items to the list.
    for (SIZE i = 0; i < 0x10; ++i) {
        item_l_p = OS_ListItemCreate();
        if (OS_NULL == item_l_p) {
            OS_TRACE(D_CRITICAL, "No memory!\n", OS_NULL);
        }
        OS_LIST_ITEM_VALUE_SET(item_l_p, (OS_Value)(rand() % U8_MAX));
        OS_ListAppend(&os_test_list, item_l_p);
    }
    OS_LOG(D_DEBUG, "Initial list:");
    TestListLog(&os_test_list);
    // Sort the list.
    TestListSort(&os_test_list, SORT_ASCENDING);
    OS_LOG(D_DEBUG, "List sorted by ascending:");
    TestListLog(&os_test_list);
    TestListSort(&os_test_list, SORT_DESCENDING);
    OS_LOG(D_DEBUG, "List sorted by descending:");
    TestListLog(&os_test_list);
    OS_TRACE(D_DEBUG, "\n", OS_NULL);
    // Clean up.
    item_l_p = OS_LIST_ITEM_NEXT_GET((OS_ListItem*)&OS_LIST_ITEM_LAST_GET(&os_test_list));
    while (OS_TRUE != OS_LIST_IS_EMPTY(&os_test_list)) {
        item_next_p = OS_LIST_ITEM_NEXT_GET(item_l_p);
        OS_ListItemDelete(item_l_p);
        item_l_p = item_next_p;
    }
}
Ejemplo n.º 5
0
void Statement::close()
{
	if(m_statement != nullptr)
	{
		sqlite3_stmt *statement = m_statement;
		m_statement = nullptr;		// Resetta il puntatore allo statement

		sqlite_int res = safe_sqlite_finalize(statement);
		// La chiusura  richiamata nel distruttore pertanto non deve lanciare eccezioni
		if(res != SQLITE_OK)
		{
			OS_TRACE(sqlite_last_error(m_connection, res));
			OS_ASSERTFALSE();
		}
	}

	m_connection = nullptr;
}
Ejemplo n.º 6
0
void MemoryTracker::impl::reportMemoryLeaks()
{
	boost::recursive_mutex::scoped_lock reportLeaksLock(m_cs);

	m_finalizing = true;

	if(m_blocks.empty())
	{
		OS_ASSERT(m_memory == 0);
		return;
	}

	std::stringstream stream;
	stream << "Detected " << m_blocks.size() << " memory leak(s) (" << m_memory << " bytes):" << std::endl;
	OS_TRACE(stream.str());

	size_t memory = 0;
	for(MemoryBlocks::const_iterator i = m_blocks.begin(); i != m_blocks.end(); ++i)
	{
		shared_ptr<MemoryBlock> block = i->second;

		size_t size = block->getSize();
		const std::string &file = block->getFile();
		size_t line = block->getLine();
		const std::string &function = block->getFunction();
		
		std::stringstream leak;
		leak << "\t" << size << " byte(s) at address 0x";
		leak << i->first;
		leak << ", allocation " << block->getAllocation();
		if(block->getReallocated())
			leak << " (reallocated memory block)";

		leak << std::endl;

		OS_TRACE_CUSTOM(leak.str(), file.c_str(), static_cast<uint32>(line), function.c_str());

		memory += size;
	}
	OS_ASSERT(memory == m_memory);
}
Ejemplo n.º 7
0
ACE_INLINE pid_t
OS::waitpid (pid_t pid,
                 ACE_exitcode *status,
                 int wait_options,
                 ACE_HANDLE handle)
{
  OS_TRACE ("OS::waitpid");
#if defined (ACE_LACKS_WAITPID)
  ACE_UNUSED_ARG (pid);
  ACE_UNUSED_ARG (status);
  ACE_UNUSED_ARG (wait_options);
  ACE_UNUSED_ARG (handle);

  ACE_NOTSUP_RETURN (0);
#elif defined (ACE_WIN32)
  int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
    ? 0 /* don't hang */
    : INFINITE;

  ACE_HANDLE phandle = handle;

  if (phandle == 0)
    {
      phandle = ::OpenProcess (SYNCHRONIZE,
                               FALSE,
                               pid);

      if (phandle == 0)
        {
          OS::set_errno_to_last_error ();
          return -1;
        }
    }

  pid_t result = pid;

  // Don't try to get the process exit status if wait failed so we can
  // keep the original error code intact.
  switch (::WaitForSingleObject (phandle,
                                 blocking_period))
    {
    case WAIT_OBJECT_0:
      if (status != 0)
        // The error status of <GetExitCodeProcess> is nonetheless
        // not tested because we don't know how to return the value.
        ::GetExitCodeProcess (phandle,
                              status);
      break;
    case WAIT_TIMEOUT:
      errno = ETIME;
      result = 0;
      break;
    default:
      OS::set_errno_to_last_error ();
      result = -1;
    }
  if (handle == 0)
    ::CloseHandle (phandle);
  return result;
#elif defined(ACE_TANDEM_T1248_PTHREADS)
  ACE_UNUSED_ARG (handle);
  OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
                     pid_t, -1);
#else
  ACE_UNUSED_ARG (handle);
  OSCALL_RETURN (::waitpid (pid, status, wait_options),
                     pid_t, -1);
#endif /* ACE_LACKS_WAITPID */
}