mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-24 07:16:43 +00:00
More consistent use of sleep_ms
This commit is contained in:
parent
e98592a7c1
commit
8fea1523b1
@ -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);
|
WHYF("Serval process already running (pid=%d), but no responding.", pid);
|
||||||
if (pid>-1) {
|
if (pid>-1) {
|
||||||
kill(pid,SIGHUP); sleep(1);
|
kill(pid,SIGHUP);
|
||||||
|
sleep_ms(1000);
|
||||||
status=server_probe(&pid);
|
status=server_probe(&pid);
|
||||||
if (status!=SERVER_NOTRUNNING) {
|
if (status!=SERVER_NOTRUNNING) {
|
||||||
WHY("Tried to stop stuck servald process, but attempt failed.");
|
WHY("Tried to stop stuck servald process, but attempt failed.");
|
||||||
|
@ -276,10 +276,7 @@ int fd_poll()
|
|||||||
call_stats.totals=&poll_stats;
|
call_stats.totals=&poll_stats;
|
||||||
fd_func_enter(__HERE__, &call_stats);
|
fd_func_enter(__HERE__, &call_stats);
|
||||||
if (fdcount==0){
|
if (fdcount==0){
|
||||||
if (ms>=1000)
|
sleep_ms(ms);
|
||||||
sleep(ms/1000);
|
|
||||||
else
|
|
||||||
usleep(ms*1000);
|
|
||||||
}else{
|
}else{
|
||||||
if (config.debug.io) DEBUGF("poll(X,%d,%d)",fdcount,ms);
|
if (config.debug.io) DEBUGF("poll(X,%d,%d)",fdcount,ms);
|
||||||
r = poll(fds, fdcount, ms);
|
r = poll(fds, fdcount, ms);
|
||||||
|
2
os.c
2
os.c
@ -96,7 +96,7 @@ int urandombytes(unsigned char *buf, unsigned long long len)
|
|||||||
for (tries = 0; tries < 4; ++tries) {
|
for (tries = 0; tries < 4; ++tries) {
|
||||||
urandomfd = open("/dev/urandom",O_RDONLY);
|
urandomfd = open("/dev/urandom",O_RDONLY);
|
||||||
if (urandomfd != -1) break;
|
if (urandomfd != -1) break;
|
||||||
sleep(1);
|
sleep_ms(1000);
|
||||||
}
|
}
|
||||||
if (urandomfd == -1) {
|
if (urandomfd == -1) {
|
||||||
WHY_perror("open(/dev/urandom)");
|
WHY_perror("open(/dev/urandom)");
|
||||||
|
@ -183,7 +183,7 @@ int _ob_makespace(struct __sourceloc __whence, struct overlay_buffer *b,int byte
|
|||||||
if (corrupt) {
|
if (corrupt) {
|
||||||
WHYF("!!!!!! %d corrupted bytes in overrun catch tray", corrupt);
|
WHYF("!!!!!! %d corrupted bytes in overrun catch tray", corrupt);
|
||||||
dump("overrun catch tray",&b->bytes[b->allocSize],4096);
|
dump("overrun catch tray",&b->bytes[b->allocSize],4096);
|
||||||
sleep(3600);
|
sleep_ms(36000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned char *new=malloc(newSize+4096);
|
unsigned char *new=malloc(newSize+4096);
|
||||||
|
@ -70,11 +70,11 @@ int overlay_packetradio_setup_port(overlay_interface *interface)
|
|||||||
|
|
||||||
// Ask radio to report RSSI
|
// Ask radio to report RSSI
|
||||||
(void)write_all(interface->alarm.poll.fd,"\r",1);
|
(void)write_all(interface->alarm.poll.fd,"\r",1);
|
||||||
usleep(600000);
|
sleep_ms(600);
|
||||||
(void)write_all(interface->alarm.poll.fd,"\r",1);
|
(void)write_all(interface->alarm.poll.fd,"\r",1);
|
||||||
usleep(600000);
|
sleep_ms(600);
|
||||||
(void)write_all(interface->alarm.poll.fd,"+++",3);
|
(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);
|
(void)write_all(interface->alarm.poll.fd,"\rAT&T\rAT&T=RSSI\rATO\r",20);
|
||||||
if (config.debug.packetradio) {
|
if (config.debug.packetradio) {
|
||||||
tcgetattr(interface->alarm.poll.fd, &t);
|
tcgetattr(interface->alarm.poll.fd, &t);
|
||||||
|
@ -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.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -35,7 +36,7 @@ void randombytes(unsigned char *x,unsigned long long xlen)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
fd = open("/dev/urandom",O_RDONLY);
|
fd = open("/dev/urandom",O_RDONLY);
|
||||||
if (fd != -1) break;
|
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);
|
i = read(fd,x,i);
|
||||||
if (i < 1) {
|
if (i < 1) {
|
||||||
sleep(1);
|
sleep_ms(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user