btstack_run_loop_posix: log select errors, ignore data sources

This commit is contained in:
Matthias Ringwald 2022-10-31 14:22:56 +01:00
parent 20b1f198c3
commit c663093b19

View File

@ -55,6 +55,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/errno.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
@ -208,21 +209,25 @@ static void btstack_run_loop_posix_execute(void) {
} }
// wait for ready FDs // wait for ready FDs
select( highest_fd+1 , &descriptors_read, &descriptors_write, NULL, timeout); int res = select( highest_fd+1 , &descriptors_read, &descriptors_write, NULL, timeout);
if (res < 0){
btstack_run_loop_posix_data_sources_modified = 0; log_error("btstack_run_loop_posix_execute: select -> errno %u", errno);
btstack_linked_list_iterator_init(&it, &btstack_run_loop_base_data_sources); }
while (btstack_linked_list_iterator_has_next(&it) && !btstack_run_loop_posix_data_sources_modified){ if (res > 0){
btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it); btstack_run_loop_posix_data_sources_modified = 0;
log_debug("btstack_run_loop_posix_execute: check ds %p with fd %u\n", ds, ds->source.fd); btstack_linked_list_iterator_init(&it, &btstack_run_loop_base_data_sources);
if (FD_ISSET(ds->source.fd, &descriptors_read)) { while (btstack_linked_list_iterator_has_next(&it) && !btstack_run_loop_posix_data_sources_modified){
log_debug("btstack_run_loop_posix_execute: process read ds %p with fd %u\n", ds, ds->source.fd); btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it);
ds->process(ds, DATA_SOURCE_CALLBACK_READ); log_debug("btstack_run_loop_posix_execute: check ds %p with fd %u\n", ds, ds->source.fd);
} if (FD_ISSET(ds->source.fd, &descriptors_read)) {
if (btstack_run_loop_posix_data_sources_modified) break; log_debug("btstack_run_loop_posix_execute: process read ds %p with fd %u\n", ds, ds->source.fd);
if (FD_ISSET(ds->source.fd, &descriptors_write)) { ds->process(ds, DATA_SOURCE_CALLBACK_READ);
log_debug("btstack_run_loop_posix_execute: process write ds %p with fd %u\n", ds, ds->source.fd); }
ds->process(ds, DATA_SOURCE_CALLBACK_WRITE); if (btstack_run_loop_posix_data_sources_modified) break;
if (FD_ISSET(ds->source.fd, &descriptors_write)) {
log_debug("btstack_run_loop_posix_execute: process write ds %p with fd %u\n", ds, ds->source.fd);
ds->process(ds, DATA_SOURCE_CALLBACK_WRITE);
}
} }
} }
log_debug("btstack_run_loop_posix_execute: after ds check\n"); log_debug("btstack_run_loop_posix_execute: after ds check\n");