Home » Developer & Programmer » Precompilers, OCI & OCCI » Problem while DML / DDL operation when Multithreading being used.
Problem while DML / DDL operation when Multithreading being used. [message #94086] Mon, 19 January 2004 03:33
Prashant Prabhu
Messages: 1
Registered: January 2004
Junior Member
I am having a server which will do the database operations. client will connect to server through port. multiple client can connect to server (In server Multithreading is implemented). if one client connects to server then server will do all the DML /DDL operations without any problem but if 2 clients connects to server at the same time then DML /DDL operation will fail (some time i get the error not logged in, some time unable to fetch from so and so table etc)
Each thread will have different connection. i used mutex also but not used CONTEXT. Please let me know where i am going wrong.

THREADING PART IN MAIN PROGRAM :
while(1)
        {
                sock_id = accept(serverSocket,(struct sockaddr_in*)&sockAddr,&addrLen);
                //printf("Keep Running is : %dn",keep_running);
               /* if(keep_running == 0)
                {
                        printf("Signal Recived coming out n");
                        break;
                }*/
                pthread_mutex_lock(&(tCounter.mutex));
                        threadCount = tCounter.threadCount;
                pthread_mutex_unlock(&(tCounter.mutex));

                if(sock_id == -1)
                {
                        if(errno == EINTR)
                        {
                                printf("Signal Recived coming out n");
                                break;
                        }
                        else
                                continue;
                }
                nextIndex = getFree();

                // Pass the sock_id to Thread
                newSocket[[nextIndex]].socket_id = sock_id;
                // Pass the segment size to Thread
                newSocket[[nextIndex]].segment_size=segment_size;

                /*if(newSocket[[nextIndex]].socket_id>0)
                {
                }*/

                rc = pthread_create(&cur, NULL, RECEIVEBUFFER, (void*)&newSocket[[nextIndex]]);

                pthread_detach(cur);

                pthread_mutex_lock(&(tCounter.mutex));
                        tCounter.threadCount++;
                pthread_mutex_unlock(&(tCounter.mutex));
        }

PART OF FUNCTION WHICH WILL BE CALLED THRU THREAD

int rc = Connect2DB((char *)"ml", (char *)"ml");
EXEC SQL UPDATE LOG_TRANSACTION  SET STATUS='N' WHERE REF_NO=:cRefNo AND STATUS = 'D';
                  EXEC SQL COMMIT;
Previous Topic: Delete inside a cursor loop
Next Topic: Pb when linking on hp10.20 with Oracle 8.0.6 : pthread
Goto Forum:
  


Current Time: Sun Mar 03 02:27:07 CST 2024