mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 04:09:43 +03:00
coap_io_process: Fix 1ms busy loop and indefinite sleep
Replace COAP_RUN_BLOCK with COAP_IO_WAIT and COAP_RUN_NOBLOCK with COAP_IO_NO_WAIT for naming clarity. Instead of COAP_IO_NO_WAIT being 1, make it -1 to fix 1ms busy loop. Handle the case when coap_io_prepare_io returns 0 to prevent indefinite select() wait. include/coap2/net.h: Make the timeout_ms parameter uint32_t in coap_io_process*() functions to make sure special case of COAP_IO_NO_BLOCK is correctly handled on different architectures. Update COAP_IO_NO_BLOCK to -1. src/coap_io.c: Fix the 1ms busy loop and potential infinite wait in the non epoll case. man/coap_io.txt.in: Update documentation to reflect the changes. examples/coap-server.c: examples/contiki/server.c: Update to use COAP_IO WAIT and COAP_IO_NO_WAIT as appropriate.
This commit is contained in:
1 parent
66e6fca48e
commit
afefd95ceb
5 files changed
+82
-52
No files matched your search
@@ -1453,7 +1453,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
if (result > 0) {
|
||||
if (FD_ISSET(coap_fd, &readfds)) {
|
||||
result = coap_io_process(ctx, COAP_RUN_NONBLOCK);
|
||||
result = coap_io_process(ctx, COAP_IO_NO_WAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ PROCESS_THREAD(coap_server_process, ev, data)
|
||||
PROCESS_YIELD();
|
||||
if(ev == tcpip_event) {
|
||||
/* There is something to read on the endpoint */
|
||||
coap_io_process(coap_context, COAP_RUN_BLOCK);
|
||||
coap_io_process(coap_context, COAP_IO_WAIT);
|
||||
} else if (ev == PROCESS_EVENT_TIMER && etimer_expired(&dirty_timer)) {
|
||||
coap_resource_notify_observers(time_resource, NULL);
|
||||
etimer_reset(&dirty_timer);
|
||||
|
||||
Reference in new issue
Block a user