el muchacho Comfortably Numb | TheShot a écrit :
_threadCounter est initialisé a 0 dans le constructeur et le programme n'arrive pas au _threadCounter++.
Par contre my_thread_process est déclaré en static dans la classe et pas dans la définition, vous pensez que ça peut poser un problème ?
Code :
- while(1)
- {
- _newSocket = accept(_mySocketServer, (struct sockaddr *)&_sockInfoClient, (socklen_t*) &_sockInfoClientSize);
- cout<<"accept ok, newSocket = "<<_newSocket<<endl ;
- if (_newSocket != -1)
- {
- if(pthread_create ( &threadId[_threadCounter], NULL, my_thread_process, NULL ) != 0)
- {cout<< "erreur avec pthread_create "<<endl ;} //le quatrième paramètre est l'argument passé à my_thread_process
- _threadCounter++ ;
- //we don't call CloseHandle(_semaphoreHandle) because we are in an infinite loop
- }
- }
|
|
C'est juste pour l'exemple, ou tu incrémentes _threadcounter même si pthread_create foire ? Si tu vas dans le if de multiples fois, tu peux faire exploser ton tableau threadId. |