From 8fea1523b18e033545ffc9dbc7d21968d61ed97a Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 27 Aug 2013 15:14:17 +0930 Subject: [PATCH] More consistent use of sleep_ms --- commandline.c | 3 ++- fdqueue.c | 5 +---- os.c | 2 +- overlay_buffer.c | 2 +- overlay_packetradio.c | 6 +++--- randombytes.c | 5 +++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/commandline.c b/commandline.c index 21021ca0..2b72d2ed 100644 --- a/commandline.c +++ b/commandline.c @@ -686,7 +686,8 @@ int app_server_start(const struct cli_parsed *parsed, struct cli_context *contex */ WHYF("Serval process already running (pid=%d), but no responding.", pid); if (pid>-1) { - kill(pid,SIGHUP); sleep(1); + kill(pid,SIGHUP); + sleep_ms(1000); status=server_probe(&pid); if (status!=SERVER_NOTRUNNING) { WHY("Tried to stop stuck servald process, but attempt failed."); diff --git a/fdqueue.c b/fdqueue.c index 63b54a55..498f15e7 100644 --- a/fdqueue.c +++ b/fdqueue.c @@ -276,10 +276,7 @@ int fd_poll() call_stats.totals=&poll_stats; fd_func_enter(__HERE__, &call_stats); if (fdcount==0){ - if (ms>=1000) - sleep(ms/1000); - else - usleep(ms*1000); + sleep_ms(ms); }else{ if (config.debug.io) DEBUGF("poll(X,%d,%d)",fdcount,ms); r = poll(fds, fdcount, ms); diff --git a/os.c b/os.c index c1b4fdfc..22566057 100644 --- a/os.c +++ b/os.c @@ -96,7 +96,7 @@ int urandombytes(unsigned char *buf, unsigned long long len) for (tries = 0; tries < 4; ++tries) { urandomfd = open("/dev/urandom",O_RDONLY); if (urandomfd != -1) break; - sleep(1); + sleep_ms(1000); } if (urandomfd == -1) { WHY_perror("open(/dev/urandom)"); diff --git a/overlay_buffer.c b/overlay_buffer.c index ceaf78cc..ef3c50ef 100644 --- a/overlay_buffer.c +++ b/overlay_buffer.c @@ -183,7 +183,7 @@ int _ob_makespace(struct __sourceloc __whence, struct overlay_buffer *b,int byte if (corrupt) { WHYF("!!!!!! %d corrupted bytes in overrun catch tray", corrupt); dump("overrun catch tray",&b->bytes[b->allocSize],4096); - sleep(3600); + sleep_ms(36000000); } } unsigned char *new=malloc(newSize+4096); diff --git a/overlay_packetradio.c b/overlay_packetradio.c index 38e7368a..0b3eb330 100644 --- a/overlay_packetradio.c +++ b/overlay_packetradio.c @@ -70,11 +70,11 @@ int overlay_packetradio_setup_port(overlay_interface *interface) // Ask radio to report RSSI (void)write_all(interface->alarm.poll.fd,"\r",1); - usleep(600000); + sleep_ms(600); (void)write_all(interface->alarm.poll.fd,"\r",1); - usleep(600000); + sleep_ms(600); (void)write_all(interface->alarm.poll.fd,"+++",3); - usleep(1200000); + sleep_ms(1200); (void)write_all(interface->alarm.poll.fd,"\rAT&T\rAT&T=RSSI\rATO\r",20); if (config.debug.packetradio) { tcgetattr(interface->alarm.poll.fd, &t); diff --git a/randombytes.c b/randombytes.c index 0e0ee0a7..3f2925a5 100644 --- a/randombytes.c +++ b/randombytes.c @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "os.h" #include #include #include @@ -35,7 +36,7 @@ void randombytes(unsigned char *x,unsigned long long xlen) for (;;) { fd = open("/dev/urandom",O_RDONLY); if (fd != -1) break; - sleep(1); + sleep_ms(1000); } } @@ -44,7 +45,7 @@ void randombytes(unsigned char *x,unsigned long long xlen) i = read(fd,x,i); if (i < 1) { - sleep(1); + sleep_ms(1000); continue; }