]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
Do not use pthread_kill to stop a thread
[stg.git] / projects / stargazer / plugins / authorization / inetaccess / inetaccess.cpp
index 1eac0ab1f7fc462bfe72556aec021aaecff17593..a6d2073abe709b4457f186f0e6bf4d2b3d58d25a 100644 (file)
@@ -431,31 +431,6 @@ if (isRunningRun)
         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 (isRunningRun)
-        {
-        if (pthread_kill(recvThread, SIGINT))
-            {
-            errorStr = "Cannot kill thread.";
-            printfd(__FILE__, "Cannot kill thread\n");
-            return -1;
-            }
-        for (int i = 0; i < 25 && isRunningRun; ++i)
-            {
-            struct timespec ts = {0, 200000000};
-            nanosleep(&ts, NULL);
-            }
-        if (isRunningRun)
-            {
-            printfd(__FILE__, "Failed to stop recv thread\n");
-            }
-        else
-            {
-            pthread_join(recvThread, NULL);
-            }
-        printfd(__FILE__, "AUTH_IA killed Run\n");
-        }
     }
 
 FinalizeNet();
     }
 
 FinalizeNet();
@@ -468,33 +443,14 @@ if (isRunningRunTimeouter)
         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 (isRunningRunTimeouter)
-        {
-        if (pthread_kill(timeouterThread, SIGINT))
-            {
-            errorStr = "Cannot kill thread.";
-            return -1;
-            }
-        for (int i = 0; i < 25 && isRunningRunTimeouter; ++i)
-            {
-            struct timespec ts = {0, 200000000};
-            nanosleep(&ts, NULL);
-            }
-        if (isRunningRunTimeouter)
-            {
-            printfd(__FILE__, "Failed to stop timeouter thread\n");
-            }
-        else
-            {
-            pthread_join(timeouterThread, NULL);
-            }
-        printfd(__FILE__, "AUTH_IA killed Timeouter\n");
-        }
     }
     }
-printfd(__FILE__, "AUTH_IA::Stoped successfully.\n");
+
 users->DelNotifierUserDel(&onDelUserNotifier);
 users->DelNotifierUserDel(&onDelUserNotifier);
+
+if (isRunningRun || isRunningRunTimeouter)
+    return -1;
+
+printfd(__FILE__, "AUTH_IA::Stoped successfully.\n");
 return 0;
 }
 //-----------------------------------------------------------------------------
 return 0;
 }
 //-----------------------------------------------------------------------------