mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
btstack_run_loop_posix:: support error condition for file descriptors in btstack_run_loop
This commit is contained in:
parent
cef0622537
commit
b30edfda79
@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- HID Host: storage for HID Descriptors is now optional
|
||||
- HCI: support newer AIROC Controller that require Download Mode with ENABLE_AIROC_DOWNLOAD_MODE
|
||||
- Zephyr: provide hal_flash_bank implementation for native flash driver
|
||||
|
||||
- POSIX: support error condition for file descriptors in btstack_run_loop
|
||||
|
||||
### Fixed
|
||||
- GAP: store link key for standard/non-SSP pairing
|
||||
- BENP: emit channel opened with ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION if connection cannot be set up
|
||||
|
@ -160,7 +160,8 @@ static uint32_t btstack_run_loop_posix_get_time_ms(void){
|
||||
static void btstack_run_loop_posix_execute(void) {
|
||||
fd_set descriptors_read;
|
||||
fd_set descriptors_write;
|
||||
|
||||
fd_set descriptors_error;
|
||||
|
||||
btstack_linked_list_iterator_t it;
|
||||
struct timeval * timeout;
|
||||
struct timeval tv;
|
||||
@ -179,6 +180,7 @@ static void btstack_run_loop_posix_execute(void) {
|
||||
// collect FDs
|
||||
FD_ZERO(&descriptors_read);
|
||||
FD_ZERO(&descriptors_write);
|
||||
FD_ZERO(&descriptors_error);
|
||||
int highest_fd = -1;
|
||||
btstack_linked_list_iterator_init(&it, &btstack_run_loop_base_data_sources);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
@ -198,6 +200,13 @@ static void btstack_run_loop_posix_execute(void) {
|
||||
}
|
||||
log_debug("btstack_run_loop_execute adding fd %u for write", ds->source.fd);
|
||||
}
|
||||
if (ds->flags & DATA_SOURCE_CALLBACK_ERROR){
|
||||
FD_SET(ds->source.fd, &descriptors_error);
|
||||
if (ds->source.fd > highest_fd) {
|
||||
highest_fd = ds->source.fd;
|
||||
}
|
||||
log_debug("btstack_run_loop_execute adding fd %u for error", ds->source.fd);
|
||||
}
|
||||
}
|
||||
|
||||
// get next timeout
|
||||
@ -231,6 +240,11 @@ static void btstack_run_loop_posix_execute(void) {
|
||||
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_error)) {
|
||||
log_debug("btstack_run_loop_posix_execute: process error ds %p with fd %u\n", ds, ds->source.fd);
|
||||
ds->process(ds, DATA_SOURCE_CALLBACK_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
log_debug("btstack_run_loop_posix_execute: after ds check\n");
|
||||
|
@ -75,6 +75,7 @@ typedef enum {
|
||||
DATA_SOURCE_CALLBACK_POLL = 1 << 0,
|
||||
DATA_SOURCE_CALLBACK_READ = 1 << 1,
|
||||
DATA_SOURCE_CALLBACK_WRITE = 1 << 2,
|
||||
DATA_SOURCE_CALLBACK_ERROR = 1 << 3,
|
||||
} btstack_data_source_callback_type_t;
|
||||
|
||||
typedef struct btstack_data_source {
|
||||
|
Loading…
x
Reference in New Issue
Block a user