mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-08 11:34:13 +00:00
Be more careful setting alarm times
This commit is contained in:
parent
15cdcc4380
commit
998a40938b
@ -288,7 +288,7 @@ int fd_poll()
|
||||
{
|
||||
IN();
|
||||
int i, r=0;
|
||||
int ms=60000;
|
||||
time_ms_t ms=60000;
|
||||
time_ms_t now = gettime_ms();
|
||||
|
||||
if (!next_alarm && !next_deadline && fdcount==0)
|
||||
@ -317,7 +317,8 @@ int fd_poll()
|
||||
call_stats.totals=&poll_stats;
|
||||
fd_func_enter(__HERE__, &call_stats);
|
||||
if (fdcount==0){
|
||||
sleep_ms(ms);
|
||||
if (ms)
|
||||
sleep_ms(ms);
|
||||
}else{
|
||||
r = poll(fds, fdcount, ms);
|
||||
if (config.debug.io) {
|
||||
|
@ -123,4 +123,6 @@ unsigned fd_depth();
|
||||
#define RETURNNULL(X) do { X; OUT(); return (NULL); } while (0)
|
||||
#define RETURNVOID do { OUT(); return; } while (0)
|
||||
|
||||
void list_alarms();
|
||||
|
||||
#endif // __SERVAL_DNA__FDQUEUE_H
|
||||
|
11
msp_client.c
11
msp_client.c
@ -657,16 +657,16 @@ static int process_sock(struct msp_sock *sock)
|
||||
|
||||
int msp_processing(time_ms_t *next_action)
|
||||
{
|
||||
*next_action=TIME_MS_NEVER_WILL;
|
||||
time_ms_t next=TIME_MS_NEVER_WILL;
|
||||
struct msp_sock *sock = root;
|
||||
while(sock){
|
||||
if (!(sock->state & MSP_STATE_CLOSED)) {
|
||||
// this might cause the socket to be closed
|
||||
// remember the time of the next thing we need to do.
|
||||
if (process_sock(sock)==0 && sock->next_action < *next_action)
|
||||
*next_action=sock->next_action;
|
||||
}else if (sock->next_action < *next_action)
|
||||
*next_action=sock->next_action;
|
||||
if (process_sock(sock)==0 && sock->next_action < next)
|
||||
next=sock->next_action;
|
||||
}else if (sock->next_action < next)
|
||||
next=sock->next_action;
|
||||
if (sock->state & MSP_STATE_CLOSED){
|
||||
struct msp_sock *s = sock->_next;
|
||||
msp_free(sock);
|
||||
@ -675,6 +675,7 @@ int msp_processing(time_ms_t *next_action)
|
||||
sock = sock->_next;
|
||||
}
|
||||
}
|
||||
*next_action=next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -305,13 +305,15 @@ static void msp_poll(struct sched_ent *alarm)
|
||||
msp_recv(alarm->poll.fd);
|
||||
|
||||
// do any timed actions that need to be done, either in response to receiving or due to a timed alarm.
|
||||
msp_processing(&alarm->alarm);
|
||||
if (alarm->alarm){
|
||||
time_ms_t next;
|
||||
msp_processing(&next);
|
||||
unschedule(alarm);
|
||||
if (next != TIME_MS_NEVER_WILL){
|
||||
time_ms_t now = gettime_ms();
|
||||
alarm->alarm=next;
|
||||
if (alarm->alarm < now)
|
||||
alarm->alarm = now;
|
||||
alarm->deadline = alarm->alarm +10;
|
||||
unschedule(alarm);
|
||||
schedule(alarm);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user