]> git.stg.codes - stg.git/blobdiff - stglibs/pinger.lib/pinger.cpp
Do not use pthread_kill to stop a thread
[stg.git] / stglibs / pinger.lib / pinger.cpp
index 8e6370ed4774c257bb9aea21cc78208025bedfbd..af761ffa8b73df2f511f68911507a128bf135a29 100644 (file)
@@ -98,16 +98,6 @@ if (isRunningRecver)
         struct timespec ts = {0, 200000000};
         nanosleep(&ts, NULL);
         }
         struct timespec ts = {0, 200000000};
         nanosleep(&ts, NULL);
         }
-
-    //after 5 seconds waiting thread still running. now killing it
-    if (isRunningRecver)
-        {
-        if (pthread_kill(recvThread, SIGINT))
-            {
-            errorStr = "Cannot kill thread.";
-            return -1;
-            }
-        }
     }
 
 if (isRunningSender)
     }
 
 if (isRunningSender)
@@ -121,19 +111,13 @@ if (isRunningSender)
         struct timespec ts = {0, 200000000};
         nanosleep(&ts, NULL);
         }
         struct timespec ts = {0, 200000000};
         nanosleep(&ts, NULL);
         }
-
-    //after 5 seconds waiting thread still running. now killing it
-    if (isRunningSender)
-        {
-        if (pthread_kill(sendThread, SIGINT))
-            {
-            errorStr = "Cannot kill thread.";
-            return -1;
-            }
-        }
     }
 
 close(sendSocket);
     }
 
 close(sendSocket);
+
+if (isRunningSender || isRunningRecver)
+    return -1;
+
 return 0;
 }
 //-----------------------------------------------------------------------------
 return 0;
 }
 //-----------------------------------------------------------------------------