Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A question about OCI_THREADED.

600577Oct 16 2007 — edited Oct 25 2007
I have just tested a simple C code and found a strange behavior I don't understand. The code looks like,

void* fn( void* arg )
{
OCIEnv* envhp;
OCIError* errhp;
OCIServer* svrhp;
...
OCIEnvCreate( OCI_DEFAULT );
OCIHandleAlloc() ...
OCIServerAttach( );
...
}

int main()
{
for( i=0; i=64; i++ )... (pthread_create(fn); )
join_all();
return 1;
}

It's a very simple code that attempts to establish multiple sessions using threads.
As far as I understand, as each thread is using its own environment and no two sessions are sharing the same envinrmnent handle, I do not need to set OCI_THREADED flag when calling OCIEnvCreate. But when I create more than about 10~15 threads with OCI_DEFAULT, it always crashes at OCIServerAttach. With OCI_THREADED, ok.

However, what is more strange is that if I manually serialize connection establishment phase using mutex without OCI_THREADED option, everything works well afterwards.

Am I missing something?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2007
Added on Oct 16 2007
6 comments
2,923 views