vrogier / ocilib

OCILIB (C and C++ Drivers for Oracle) - Open source C and C++ library for accessing Oracle databases

Home Page:http://www.ocilib.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Selecting ADT object hangs when OCILIB initialized with OCI_ENV_THREADED in develop-4.7.5

iliasaz opened this issue · comments

Hi Vincent,

While working in develop-4.7.5 branch, there seems to be a mutex issue when selecting an object value in SELECT list and when OCILIB is initialized with OCI_ENV_THREADED flag. It works fine without OCI_ENV_THREADED. Here is a test case:

#include <stdio.h>
#include "ocilib.h"

void err_handler(OCI_Error* err)
{
    printf(OCI_ErrorGetString(err));
}

int main(void)
{
    OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT | OCI_ENV_CONTEXT | OCI_ENV_THREADED); // <<< hangs
//    OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT | OCI_ENV_CONTEXT); <<< works
   
    OCI_Connection* cn = OCI_ConnectionCreate("database", "user", "passwd", OCI_SESSION_DEFAULT);
    OCI_Statement* st = OCI_StatementCreate(cn);

    OCI_ExecuteStmt(st, "select ora_mining_number_nt(1,2,3) as v from dual");
    OCI_Resultset* rs = OCI_GetResultset(st);
    while (OCI_FetchNext(rs))
    {
        printf("%s\n", OCI_GetString(rs, 1));
    }

    OCI_Cleanup();
}

It seems to be getting stuck in this stack:

OcilibTypeInfoFindOrCreate => LIST_ATOMIC_FIND(con->tinfs, OcilibTypeInfoFind, p_find_params, typinf) => OcilibListLock => OcilibMutexAcquire => OCIThreadMutexAcquire

Thanks.

Hi,

This has already been fixed in commit db231f7 on Oct 6th.
In this commit LIST_ATOMIC_FIND has been removed from OcilibTypeInfoFindOrCreate()

Regards,

Vincent

Great! Thank you.