Exemple #1
0
OCI_Mutex * OCI_MutexCreateInternal
(
    void
)
{
    OCI_CALL_DECLARE_CONTEXT(TRUE)
        
    OCI_Mutex *mutex = NULL;

    /* allocate mutex structure */

    mutex = (OCI_Mutex *) OCI_MemAlloc(OCI_IPC_MUTEX, sizeof(*mutex), (size_t) 1, TRUE);
    OCI_STATUS = (NULL != mutex);

    if (OCI_STATUS)
    {
        /* allocate error handle */

        OCI_STATUS = OCI_HandleAlloc(OCILib.env, (dvoid **)(void *)&mutex->err, OCI_HTYPE_ERROR);

        /* allocate mutex handle */

        OCI_EXEC(OCIThreadMutexInit(OCILib.env, mutex->err, &mutex->handle))
    }

    if (!OCI_STATUS && mutex)
    {
        OCI_MutexFree(mutex);
        mutex = NULL;
    }

    return mutex;
}
Exemple #2
0
boolean OCI_ListFree
(
    OCI_List *list
)
{
    boolean res = TRUE;

    OCI_CHECK(list == NULL, FALSE);

    OCI_ListClear(list);

    if (list->mutex != NULL)
    {
        res = OCI_MutexFree(list->mutex);
    }

    OCI_FREE(list);

    return res;
}
Exemple #3
0
OCI_Mutex * OCI_MutexCreateInternal
(
    void
)
{
    OCI_Mutex *mutex = NULL;
    boolean    res   = FALSE;

    /* allocate mutex structure */

    mutex = (OCI_Mutex *) OCI_MemAlloc(OCI_IPC_MUTEX, sizeof(*mutex), (size_t) 1, TRUE);

    if (mutex)
    {
        /* allocate error handle */

        res = OCI_SUCCESSFUL(OCI_HandleAlloc(OCILib.env, (dvoid **) (void *) &mutex->err,
                                             OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) NULL));

        /* allocate mutex handle */

        OCI_CALL3
        (
            res, mutex->err,

            OCIThreadMutexInit(OCILib.env, mutex->err, &mutex->handle)
        )
    }

    if (!res && mutex)
    {
        OCI_MutexFree(mutex);
        mutex = NULL;
    }

    return mutex;
}
Exemple #4
0
boolean OCI_PoolClose
(
    OCI_Pool *pool
)
{
    boolean res = TRUE;

    OCI_CHECK_PTR(OCI_IPC_POOL, pool, FALSE);

    /* free all connections */

    OCI_ListForEach(pool->cons, (POCI_LIST_FOR_EACH) OCI_ConnectionClose);
    OCI_ListClear(pool->cons);
    OCI_ListFree(pool->cons);

    pool->cons = NULL;

    if (OCI_LIB_THREADED)
    {
        OCI_MutexFree(pool->mutex);
    }

 #if OCI_VERSION_COMPILE >= OCI_9_0

    if (OCILib.version_runtime >= OCI_9_0)
    {
        /* close pool handle */

        if (pool->handle != NULL)
        {
            if (pool->htype == OCI_HTYPE_CPOOL)
            {
                OCI_CALL0
                (
                    res, pool->err,

                    OCIConnectionPoolDestroy(pool->handle, pool->err,
                                             (ub4) OCI_DEFAULT)
                )
            }

        #if OCI_VERSION_COMPILE >= OCI_9_2

            else
            {
                OCI_CALL0
                (
                    res, pool->err,

                    OCISessionPoolDestroy(pool->handle, pool->err,
                                          (ub4) OCI_SPD_FORCE)
                )
            }

        #endif

            OCI_HandleFree((void *) pool->handle, (ub4) pool->htype);
        }

    #if OCI_VERSION_COMPILE >= OCI_9_2

        /* close authentification handle */

        if (pool->authp != NULL)
        {
            OCI_HandleFree((void *) pool->authp, (ub4) OCI_HTYPE_AUTHINFO);
        }

    #endif

        /* close error handle */

        if (pool->err != NULL)
        {
            OCI_HandleFree((void *) pool->err, (ub4) OCI_HTYPE_ERROR);
        }
    }

#endif

    pool->err    = NULL;
    pool->handle = NULL;
    pool->authp  = NULL;

    /* free strings */

    OCI_FREE(pool->name);
    OCI_FREE(pool->db);
    OCI_FREE(pool->user);
    OCI_FREE(pool->pwd);

    return res;
}