소스 검색

Ajout detach thread client + msg erreur quand detach fail

Arthur Brandao 6 년 전
부모
커밋
9b644077d0
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      Serveur/bomberstudent_server.c

+ 8 - 1
Serveur/bomberstudent_server.c

@@ -42,6 +42,11 @@ void* client_thread(void* data) {
     //Recup la valeur de data
     tmp = (int*) data;
     cliId = *tmp;
+    //Detache le thread
+    if (pthread_detach(pthread_self()) != 0) {
+        adderror("Impossible de détacher le thread Client");
+        return NULL;
+    }
     //Recup le client
     cli = get_client(cliId);
     if (cli == NULL) {
@@ -85,6 +90,7 @@ void* udp_thread(void* data) {
     s = (Server) data;
     //Detache le thread
     if (pthread_detach(pthread_self()) != 0) {
+        adderror("Impossible de détacher le thread UDP");
         return NULL;
     }
     //Boucle attente
@@ -118,6 +124,7 @@ void* tcp_thread(void* data) {
     s = (Server*) data;
     //Detache le thread
     if (pthread_detach(pthread_self()) != 0) {
+        adderror("Impossible de détacher le thread TCP");
         return NULL;
     }
     //Boucle attente
@@ -131,7 +138,7 @@ void* tcp_thread(void* data) {
         //Creation d'un client et de son thread
         cliId = add_client(s[0], s[1]);
         if (pthread_create(&client, NULL, client_thread, &cliId) != 0) {
-            adderror("Impossible de créer le thread CLient");
+            adderror("Impossible de créer le thread Client");
             /*ToDo Avertir Client du probleme*/
         }
     }