git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bfb8d76
)
Replace deprecated usleep with POSIX-compliant nanosleep
author
Maxim Mamontov
<faust.madf@gmail.com>
Fri, 16 Sep 2011 16:11:58 +0000
(19:11 +0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Fri, 16 Sep 2011 16:11:58 +0000
(19:11 +0300)
19 files changed:
projects/rscriptd/listener.cpp
patch
|
blob
|
history
projects/rscriptd/main.cpp
patch
|
blob
|
history
projects/sgauth/main.cpp
patch
|
blob
|
history
projects/sgauth/web.cpp
patch
|
blob
|
history
projects/sgauthstress/main.cpp
patch
|
blob
|
history
projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
patch
|
blob
|
history
projects/stargazer/plugins/authorization/stress/stress.cpp
patch
|
blob
|
history
projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
patch
|
blob
|
history
projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
patch
|
blob
|
history
projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp
patch
|
blob
|
history
projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp
patch
|
blob
|
history
projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp
patch
|
blob
|
history
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
patch
|
blob
|
history
projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
patch
|
blob
|
history
projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp
patch
|
blob
|
history
projects/stargazer/plugins/other/radius/radius.cpp
patch
|
blob
|
history
projects/stargazer/plugins/other/rscript/rscript.cpp
patch
|
blob
|
history
stglibs/ia.lib/ia.cpp
patch
|
blob
|
history
stglibs/pinger.lib/pinger.cpp
patch
|
blob
|
history
diff --git
a/projects/rscriptd/listener.cpp
b/projects/rscriptd/listener.cpp
index 9e03988c2f116cd9e8283b372c49afe3f9a6beb1..d4f2dc937b56401519bca2dbdeffb546cf450639 100644
(file)
--- a/
projects/rscriptd/listener.cpp
+++ b/
projects/rscriptd/listener.cpp
@@
-102,14
+102,16
@@
running = false;
printfd(__FILE__, "LISTENER::Stop()\n");
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++)
{
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
}
//after 5 seconds waiting thread still running. now killing it
@@
-130,7
+132,8
@@
if (!receiverStopped)
//5 seconds to thread stops itself
for (int i = 0; i < 25 && !receiverStopped; i++)
{
//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
}
//after 5 seconds waiting thread still running. now killing it
@@
-196,7
+199,8
@@
processorStopped = false;
while (running)
{
while (running)
{
- usleep(500000);
+ struct timespec ts = {0, 500000000};
+ nanosleep(&ts, NULL);
if (!pending.empty())
ProcessPending();
ProcessTimeouts();
if (!pending.empty())
ProcessPending();
ProcessTimeouts();
diff --git
a/projects/rscriptd/main.cpp
b/projects/rscriptd/main.cpp
index 7e7f7f355e257f2e10d61a3cec9d65d53eaf241a..2739758ce400cb9f49cd62d1287736888fdf8614 100644
(file)
--- a/
projects/rscriptd/main.cpp
+++ b/
projects/rscriptd/main.cpp
@@
-430,7
+430,8
@@
WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++");
while (nonstop.GetStatus())
{
while (nonstop.GetStatus())
{
- usleep(100000);
+ struct timespec ts = {0, 100000000};
+ nanosleep(&ts, NULL);
}
listener->Stop();
}
listener->Stop();
diff --git
a/projects/sgauth/main.cpp
b/projects/sgauth/main.cpp
index 96c58203ec78c5d5463cae2a52eada20232ef723..2af78b71f7667e7960d6db0ec4076e24574becd6 100644
(file)
--- a/
projects/sgauth/main.cpp
+++ b/
projects/sgauth/main.cpp
@@
-239,7
+239,8
@@
clnp->Connect();
while (1)
{
while (1)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
char state[20];
char state[20];
diff --git
a/projects/sgauth/web.cpp
b/projects/sgauth/web.cpp
index 6e2d4acadbed89607ba7feb3b5fc35b45261031c..ab169cc49160f0813878ef7a7e1f65bce444f1f9 100644
(file)
--- a/
projects/sgauth/web.cpp
+++ b/
projects/sgauth/web.cpp
@@
-182,7
+182,8
@@
while (1)
#ifdef WIN32
Sleep(1000);
#else
#ifdef WIN32
Sleep(1000);
#else
- usleep(1000000);
+ struct timespec ts = {1, 0};
+ nanosleep(&ts, NULL);
#endif
exit(0);
}
#endif
exit(0);
}
diff --git
a/projects/sgauthstress/main.cpp
b/projects/sgauthstress/main.cpp
index 2388254dab91257ae235d096dff7f2922717f547..b0819c3c016bad9a2e163c6c96cc70f250fef511 100644
(file)
--- a/
projects/sgauthstress/main.cpp
+++ b/
projects/sgauthstress/main.cpp
@@
-157,7
+157,8
@@
std::cout << "Successfully loaded " << proto.UserCount() << " users" << std::end
running = true;
while (running)
{
running = true;
while (running)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
proto.Stop();
}
proto.Stop();
diff --git
a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
index 5e468d0fdeaddf192a616bb9869b07e10ca63d31..4986080eb82a1b4c212e3a2a7b6bbef069bf6320 100644
(file)
--- a/
projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
+++ b/
projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp
@@
-30,7
+30,7
@@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <unistd.h> //
usleep,
close
+#include <unistd.h> // close
#include <csignal>
#include <cstdlib>
#include <csignal>
#include <cstdlib>
@@
-428,7
+428,8
@@
if (isRunningRun)
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunningRun; i++)
{
//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
}
//after 5 seconds waiting thread still running. now killing it
@@
-441,7
+442,10
@@
if (isRunningRun)
return -1;
}
for (int i = 0; i < 25 && isRunningRun; ++i)
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");
if (isRunningRun)
{
printfd(__FILE__, "Failed to stop recv thread\n");
@@
-461,7
+465,8
@@
if (isRunningRunTimeouter)
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunningRunTimeouter; i++)
{
//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
}
//after 5 seconds waiting thread still running. now killing it
@@
-473,7
+478,10
@@
if (isRunningRunTimeouter)
return -1;
}
for (int i = 0; i < 25 && isRunningRunTimeouter; ++i)
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");
if (isRunningRunTimeouter)
{
printfd(__FILE__, "Failed to stop timeouter thread\n");
@@
-525,7
+533,8
@@
int a = -1;
string monFile = ia->stgSettings->GetMonitorDir() + "/inetaccess_t";
while (ia->nonstop)
{
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())
ia->Timeouter();
// TODO change counter to timer and MONITOR_TIME_DELAY_SEC
if (++a % (50 * 60) == 0 && ia->stgSettings->GetMonitoring())
diff --git
a/projects/stargazer/plugins/authorization/stress/stress.cpp
b/projects/stargazer/plugins/authorization/stress/stress.cpp
index 5d41a91dacf60b86167fe89ebc1a327daccd9f07..7273ed483479ede97445007aec28e41836a75f1e 100644
(file)
--- a/
projects/stargazer/plugins/authorization/stress/stress.cpp
+++ b/
projects/stargazer/plugins/authorization/stress/stress.cpp
@@
-176,7
+176,8
@@
if (isRunning)
{
if (!isRunning)
break;
{
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
diff --git
a/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
b/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
index 9ed507561ddb75e575d3215e0143cc01c921b514..fb7d2cc5b0f291d4ffa846be6857008bb0e8499d 100644
(file)
--- a/
projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
+++ b/
projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
@@
-148,7
+148,8
@@
if (portU && !stoppedUDP)
CloseUDP();
for (int i = 0; i < 25 && !stoppedUDP; ++i)
{
CloseUDP();
for (int i = 0; i < 25 && !stoppedUDP; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (stoppedUDP)
{
}
if (stoppedUDP)
{
@@
-170,7
+171,8
@@
if (portT && !stoppedTCP)
CloseTCP();
for (int i = 0; i < 25 && !stoppedTCP; ++i)
{
CloseTCP();
for (int i = 0; i < 25 && !stoppedTCP; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (stoppedTCP)
{
}
if (stoppedTCP)
{
diff --git
a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
index 98bf1b6c0c3e4340e1e81a462a8e318aed97773a..5927727e516a221dcc716bf87f58ef8258beaa9f 100644
(file)
--- a/
projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
+++ b/
projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp
@@
-130,7
+130,8
@@
for (i = 0; i < 25; i++)
if (!isRunning)
break;
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
diff --git
a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp
b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp
index c415e6919e9cf4d8a16934d9745e9b22cc4160c7..108c4e0d6a9e73cbb1c02123bb72003314b88f9d 100644
(file)
--- a/
projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp
+++ b/
projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp
@@
-180,7
+180,8
@@
for (i = 0; i < 25; i++)
if (!isRunning)
break;
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
@@
-213,12
+214,11
@@
char * iface;
while (dc->nonstop)
{
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))
if (!(hdr[12] == 0x8 && hdr[13] == 0x0))
- {
continue;
continue;
- }
dc->traffCnt->Process(*rpp);
}
dc->traffCnt->Process(*rpp);
}
@@
-313,12
+313,16
@@
for (unsigned int i = 0; i < polld.size(); i++)
{
if (polld[i].revents & POLLIN)
{
{
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;
}
}
polld[i].revents = 0;
return 0;
}
}
-return
0
;
+return
-1
;
}
//-----------------------------------------------------------------------------
int BPF_CAP::BPFCapRead(char * buffer, int blen, char **, BPF_DATA * bd)
}
//-----------------------------------------------------------------------------
int BPF_CAP::BPFCapRead(char * buffer, int blen, char **, BPF_DATA * bd)
@@
-328,8
+332,9
@@
if (bd->canRead)
bd->r = read(bd->fd, bd->buffer, BUFF_LEN);
if (bd->r < 0)
{
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;
}
bd->p = bd->buffer;
diff --git
a/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp
b/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp
index 97e9b17119a7eb8fb505579b82d0abeb20d1f995..276c8df0559876d43d4bc9376b1133f38cf641ca 100644
(file)
--- a/
projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp
+++ b/
projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp
@@
-115,7
+115,8
@@
nonstop = false;
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
//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)
}
//after 5 seconds waiting thread still running. now killing it
if (isRunning)
@@
-126,7
+127,10
@@
if (isRunning)
return -1;
}
for (int i = 0; i < 25 && isRunning; ++i)
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)
{
errorStr = "ETHER_CAP not stopped.";
diff --git
a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp
b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp
index 7f60c7eb7123bc7578bd011de08eabc7d0e21d5f..84939b4e70e17e646bc8bf2a16025b64e8b45620 100644
(file)
--- a/
projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp
+++ b/
projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp
@@
-95,7
+95,8
@@
for (int i = 0; i < 25; i++)
{
if (!isRunning)
break;
{
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)
}
//after 5 seconds waiting thread still running. now killing it
if (isRunning)
@@
-107,7
+108,8
@@
if (isRunning)
}
for (int i = 0; i < 25 && isRunning; ++i)
{
}
for (int i = 0; i < 25 && isRunning; ++i)
{
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
if (isRunning)
{
}
if (isRunning)
{
diff --git
a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
index b82293d421baa9ef4a656c0ee95f7adba99dcff4..837c86496dcabfbbfd56c59228477eb5015ec7dc 100644
(file)
--- a/
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
+++ b/
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
@@
-1,5
+1,3
@@
-#include <unistd.h> // TODO: usleep
-
#include <cstdlib>
#include <csignal>
#include <cstdlib>
#include <csignal>
@@
-140,7
+138,10
@@
int RPC_CONFIG::Stop()
{
running = false;
for (int i = 0; i < 5 && !stopped; ++i)
{
running = false;
for (int i = 0; i < 5 && !stopped; ++i)
- usleep(200000);
+ {
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
+ }
//rpcServer->terminate();
if (!stopped)
{
//rpcServer->terminate();
if (!stopped)
{
@@
-150,7
+151,10
@@
if (!stopped)
printfd(__FILE__, "Failed to kill thread\n");
}
for (int i = 0; i < 25 && !stopped; ++i)
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");
if (!stopped)
{
printfd(__FILE__, "Failed to stop RPC thread\n");
diff --git
a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
index b4cbf544aa82f169049691fbfeef316251a31547..421fc7bbeb7bb7e625895aacbb1ace302b5ba88c 100644
(file)
--- a/
projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
+++ b/
projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
@@
-26,7
+26,7
@@
*
*******************************************************************/
*
*******************************************************************/
-#include <unistd.h> // clo
ase, usleep
+#include <unistd.h> // clo
se
#include <cerrno>
#include <csignal>
#include <cerrno>
#include <csignal>
diff --git
a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp
b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp
index f36792ae6e1ecda103d41b4261447babc597543d..0a65c0d9c72a06b9f35dbd958c000af4ed472644 100644
(file)
--- a/
projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp
+++ b/
projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp
@@
-123,7
+123,8
@@
for (i = 0; i < 25; i++)
if (!isRunning)
break;
if (!isRunning)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
diff --git
a/projects/stargazer/plugins/other/radius/radius.cpp
b/projects/stargazer/plugins/other/radius/radius.cpp
index 62c9305ca84ca5c9ac52099e9ab42a5b1ea3fd9d..6a02ce4f3d7ff328779d41dee45a2df41eb676f3 100644
(file)
--- a/
projects/stargazer/plugins/other/radius/radius.cpp
+++ b/
projects/stargazer/plugins/other/radius/radius.cpp
@@
-236,7
+236,8
@@
if (isRunning)
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
//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
}
//after 5 seconds waiting thread still running. now killing it
diff --git
a/projects/stargazer/plugins/other/rscript/rscript.cpp
b/projects/stargazer/plugins/other/rscript/rscript.cpp
index 6fde814a74152cb06d8a6ea5fe6eed367b3425f2..c1d66051456d922e690b03f6edb8bd52db430398 100644
(file)
--- a/
projects/stargazer/plugins/other/rscript/rscript.cpp
+++ b/
projects/stargazer/plugins/other/rscript/rscript.cpp
@@
-282,7
+282,8
@@
if (isRunning)
//5 seconds to thread stops itself
for (int i = 0; i < 25 && isRunning; i++)
{
//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
}
//after 5 seconds waiting thread still running. now killing it
diff --git
a/stglibs/ia.lib/ia.cpp
b/stglibs/ia.lib/ia.cpp
index 9883dbbb8d276dbc2cb30db284b1a2c257f6564f..abecef09f552fa4ff4f8a949402c4bc313e65429 100644
(file)
--- a/
stglibs/ia.lib/ia.cpp
+++ b/
stglibs/ia.lib/ia.cpp
@@
-69,7
+69,7
@@
static int a = 0;
if (a == 0)
{
if (a == 0)
{
-
usleep(5000
0);
+
Sleep(5
0);
a = 1;
}
a = 1;
}
@@
-82,7
+82,9
@@
return NULL;
//---------------------------------------------------------------------------
void Sleep(int ms)
{
//---------------------------------------------------------------------------
void Sleep(int ms)
{
-usleep(ms * 1000);
+long long res = ms * 1000000;
+struct timespec ts = {res / 1000000000, res % 1000000000};
+nanosleep(&ts, NULL);
}
//---------------------------------------------------------------------------
long GetTickCount()
}
//---------------------------------------------------------------------------
long GetTickCount()
diff --git
a/stglibs/pinger.lib/pinger.cpp
b/stglibs/pinger.lib/pinger.cpp
index f36868063a2b2a02d6ad1c99e00b32e02a454e13..df3793abab948d1178902388a3a0dd6103346df2 100644
(file)
--- a/
stglibs/pinger.lib/pinger.cpp
+++ b/
stglibs/pinger.lib/pinger.cpp
@@
-93,7
+93,8
@@
int STG_PINGER::Stop()
if (!isRunningRecver)
break;
if (!isRunningRecver)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
@@
-115,7
+116,8
@@
int STG_PINGER::Stop()
if (!isRunningSender)
break;
if (!isRunningSender)
break;
- usleep(200000);
+ struct timespec ts = {0, 200000000};
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now killing it
}
//after 5 seconds waiting thread still running. now killing it
@@
-315,7
+317,8
@@
void * STG_PINGER::RunSendPing(void * d)
#else
currTime = time(NULL);
#endif
#else
currTime = time(NULL);
#endif
- usleep(20000);
+ struct timespec ts = {0, 20000000};
+ nanosleep(&ts, NULL);
}
}
}
}