]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/ping/ping.cpp
Introduced logger for plugins.
[stg.git] / projects / stargazer / plugins / other / ping / ping.cpp
index c824067979e3243711ffe7f5e813b21692b0368c..00bb362d98151a56b7354cca9dd7922ae03ec2c1 100644 (file)
@@ -74,7 +74,8 @@ PING::PING()
       ChgCurrIPNotifierList(),
       ChgIPNotifierList(),
       onAddUserNotifier(*this),
-      onDelUserNotifier(*this)
+      onDelUserNotifier(*this),
+      logger(GetPluginLogger(GetStgLogger(), "ping"))
 {
 pthread_mutex_init(&mutex, NULL);
 }
@@ -133,19 +134,6 @@ for (int i = 0; i < 25; i++)
     nanosleep(&ts, NULL);
     }
 
-//after 5 seconds waiting thread still running. now kill it
-if (isRunning)
-    {
-    printfd(__FILE__, "kill PING thread.\n");
-    if (pthread_kill(thread, SIGINT))
-        {
-        errorStr = "Cannot kill PING thread.";
-        printfd(__FILE__, "Cannot kill PING thread.\n");
-        return -1;
-        }
-    printfd(__FILE__, "PING killed\n");
-    }
-
 users->DelNotifierUserAdd(&onAddUserNotifier);
 users->DelNotifierUserDel(&onDelUserNotifier);
 
@@ -157,6 +145,9 @@ while (users_iter != usersList.end())
     ++users_iter;
     }
 
+if (isRunning)
+    return -1;
+
 return 0;
 }
 //-----------------------------------------------------------------------------
@@ -167,7 +158,11 @@ return isRunning;
 //-----------------------------------------------------------------------------
 void * PING::Run(void * d)
 {
-PING * ping = (PING *)d;
+sigset_t signalSet;
+sigfillset(&signalSet);
+pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
+
+PING * ping = static_cast<PING *>(d);
 ping->isRunning = true;
 
 long delay = (10000000 * ping->pingSettings.GetPingDelay()) / 3 + 50000000;