printfd(__FILE__, "LISTENER::Stop()\n");
-usleep(500000);
+struct timespec ts = {0, 500000000};
+nanosleep(&ts, NULL);
if (!processorStopped)
{
//5 seconds to thread stops itself
for (int i = 0; i < 25 && !processorStopped; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
//5 seconds to thread stops itself
for (int i = 0; i < 25 && !receiverStopped; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
while (running)
{
- usleep(500000);
+ struct timespec ts = {0, 500000000};
+ nanosleep(&ts, NULL);
if (!pending.empty())
ProcessPending();
ProcessTimeouts();
while (nonstop.GetStatus())
{
- usleep(100000);
+ struct timespec ts = {0, 100000000};
+ nanosleep(&ts, NULL);
}
listener->Stop();
while (1)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
char state[20];
#ifdef WIN32
Sleep(1000);
#else
- usleep(1000000);
+ struct timespec ts = {1, 0};
+ nanosleep(&ts, NULL);
#endif
exit(0);
}
running = true;
while (running)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
proto.Stop();
#include <sys/types.h>
#include <sys/socket.h>
-#include <unistd.h> // usleep, close
+#include <unistd.h> // close
#include <csignal>
#include <cstdlib>
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunningRun; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
return -1;
}
for (int i = 0; i < 25 && isRunningRun; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
if (isRunningRun)
{
printfd(__FILE__, "Failed to stop recv thread\n");
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunningRunTimeouter; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
return -1;
}
for (int i = 0; i < 25 && isRunningRunTimeouter; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
if (isRunningRunTimeouter)
{
printfd(__FILE__, "Failed to stop timeouter thread\n");
string monFile = ia->stgSettings->GetMonitorDir() + "/inetaccess_t";
while (ia->nonstop)
{
- usleep(20000);
+ struct timespec ts = {0, 20000000};
+ nanosleep(&ts, NULL);
ia->Timeouter();
// TODO change counter to timer and MONITOR_TIME_DELAY_SEC
if (++a % (50 * 60) == 0 && ia->stgSettings->GetMonitoring())
{
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
CloseUDP();
for (int i = 0; i < 25 && !stoppedUDP; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (stoppedUDP)
{
CloseTCP();
for (int i = 0; i < 25 && !stoppedTCP; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (stoppedTCP)
{
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
while (dc->nonstop)
{
- dc->BPFCapRead((char*)&hdr, 68 + 14, &iface);
+ if (dc->BPFCapRead((char*)&hdr, 68 + 14, &iface))
+ continue;
if (!(hdr[12] == 0x8 && hdr[13] == 0x0))
- {
continue;
- }
dc->traffCnt->Process(*rpp);
}
{
if (polld[i].revents & POLLIN)
{
- BPFCapRead(buffer, blen, capIface, &bpfData[i]);
+ if (BPFCapRead(buffer, blen, capIface, &bpfData[i]))
+ {
+ polld[i].revents = 0;
+ continue;
+ }
polld[i].revents = 0;
return 0;
}
}
-return 0;
+return -1;
}
//-----------------------------------------------------------------------------
int BPF_CAP::BPFCapRead(char * buffer, int blen, char **, BPF_DATA * bd)
bd->r = read(bd->fd, bd->buffer, BUFF_LEN);
if (bd->r < 0)
{
- //printfd(__FILE__, " error read\n");
- usleep(20000);
+ struct timespec ts = {0, 20000000};
+ nanosleep(&ts, NULL);
+ return -1;
}
bd->p = bd->buffer;
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
if (isRunning)
return -1;
}
for (int i = 0; i < 25 && isRunning; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
if (isRunning)
{
errorStr = "ETHER_CAP not stopped.";
{
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
if (isRunning)
}
for (int i = 0; i < 25 && isRunning; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (isRunning)
{
-#include <unistd.h> // TODO: usleep
-
#include <cstdlib>
#include <csignal>
{
running = false;
for (int i = 0; i < 5 && !stopped; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
//rpcServer->terminate();
if (!stopped)
{
printfd(__FILE__, "Failed to kill thread\n");
}
for (int i = 0; i < 25 && !stopped; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
if (!stopped)
{
printfd(__FILE__, "Failed to stop RPC thread\n");
*
*******************************************************************/
-#include <unistd.h> // cloase, usleep
+#include <unistd.h> // close
#include <cerrno>
#include <csignal>
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
if (a == 0)
{
- usleep(50000);
+ Sleep(50);
a = 1;
}
//---------------------------------------------------------------------------
void Sleep(int ms)
{
-usleep(ms * 1000);
+long long res = ms * 1000000;
+struct timespec ts = {res / 1000000000, res % 1000000000};
+nanosleep(&ts, NULL);
}
//---------------------------------------------------------------------------
long GetTickCount()
if (!isRunningRecver)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
if (!isRunningSender)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
#else
currTime = time(NULL);
#endif
- usleep(20000);
+ struct timespec ts = {0, 20000000};
+ nanosleep(&ts, NULL);
}
}