Exemplo n.º 1
0
CAResult_t CATerminateNetworkType()
{
    OIC_LOG(DEBUG, TAG, "CATerminateNetworkType()");
    if (NULL != g_selectedNetworkList)
    {
        u_arraylist_free(&g_selectedNetworkList);
    }
    return CA_STATUS_OK;
}
Exemplo n.º 2
0
static void CAFreePeerInfoList()
{
    uint32_t list_length = u_arraylist_length(g_caDtlsContext->peerInfoList);
    for (uint32_t list_index = 0; list_index < list_length; list_index++)
    {
        CAEndpoint_t *peerInfo = (CAEndpoint_t *)u_arraylist_get(
                                     g_caDtlsContext->peerInfoList, list_index);
        OICFree(peerInfo);
    }
    u_arraylist_free(&(g_caDtlsContext->peerInfoList));
    g_caDtlsContext->peerInfoList = NULL;
}
Exemplo n.º 3
0
void ca_thread_pool_free(ca_thread_pool_t thread_pool)
{
    OIC_LOG(DEBUG, TAG, "IN");

    if(!thread_pool)
    {
        OIC_LOG(ERROR, TAG, "Invalid parameter thread_pool was NULL");
        return;
    }

    ca_mutex_lock(thread_pool->details->list_lock);

    for(uint32_t i = 0; i<u_arraylist_length(thread_pool->details->threads_list); ++i)
    {
        pthread_t tid = (pthread_t)u_arraylist_get(thread_pool->details->threads_list, i);
#if defined(_WIN32)
        DWORD joinres = WaitForSingleObject(tid, INFINITE);
        if (WAIT_OBJECT_0 != joinres)
        {
            OIC_LOG_V(ERROR, TAG, "Failed to join thread at index %u with error %d", i, joinres);
        }
        CloseHandle(tid);
#else
        int joinres = pthread_join(tid, NULL);
        if(0 != joinres)
        {
            OIC_LOG_V(ERROR, TAG, "Failed to join thread at index %u with error %d", i, joinres);
        }
#endif
    }

    u_arraylist_free(&(thread_pool->details->threads_list));

    ca_mutex_unlock(thread_pool->details->list_lock);
    ca_mutex_free(thread_pool->details->list_lock);

    OICFree(thread_pool->details);
    OICFree(thread_pool);

    OIC_LOG(DEBUG, TAG, "OUT");
}
Exemplo n.º 4
0
static void CAClearCacheList()
{
    OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
    uint32_t list_index = 0;
    uint32_t list_length = 0;
    if (NULL == g_caDtlsContext)
    {
        OIC_LOG(ERROR, NET_DTLS_TAG, "Dtls Context is NULL");
        return;
    }
    list_length = u_arraylist_length(g_caDtlsContext->cacheList);
    for (list_index = 0; list_index < list_length; list_index++)
    {
        stCACacheMessage_t *msg = (stCACacheMessage_t *)u_arraylist_get(g_caDtlsContext->cacheList,
                                  list_index);
        if (msg != NULL)
        {
            CAFreeCacheMsg(msg);
        }
    }
    u_arraylist_free(&g_caDtlsContext->cacheList);
    g_caDtlsContext->cacheList = NULL;
    OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
}
Exemplo n.º 5
0
void ca_thread_pool_free(ca_thread_pool_t thread_pool)
{
    OIC_LOG(DEBUG, TAG, "IN");

    if(!thread_pool)
    {
        OIC_LOG(ERROR, TAG, "Invalid parameter thread_pool was NULL");
        return;
    }

    ca_mutex_lock(thread_pool->details->list_lock);

    for(uint32_t i = 0; i<u_arraylist_length(thread_pool->details->threads_list); ++i)
    {
        pthread_t tid = (pthread_t)u_arraylist_get(thread_pool->details->threads_list, i);
        int joinres = pthread_join(tid, NULL);
        if(0 != joinres)
        {
            OIC_LOG_V(ERROR, TAG, "Failed to join thread at index %u with error %d", i, joinres);
        }
    }

    CAResult_t freeres = u_arraylist_free(&(thread_pool->details->threads_list));
    if(CA_STATUS_OK != freeres)
    {
        OIC_LOG_V(ERROR, TAG, "Failed to free array list, error was: %d", freeres);
    }

    ca_mutex_unlock(thread_pool->details->list_lock);
    ca_mutex_free(thread_pool->details->list_lock);

    OICFree(thread_pool->details);
    OICFree(thread_pool);

    OIC_LOG(DEBUG, TAG, "OUT");
}