diff options
author | Matias Karhumaa <matias.karhumaa@gmail.com> | 2021-03-19 15:00:52 +0200 |
---|---|---|
committer | Matias Karhumaa <matias.karhumaa@gmail.com> | 2021-03-19 15:00:52 +0200 |
commit | 747ca9149a4158fafc4551550976cdb028916182 (patch) | |
tree | de649b071a5b56a2cc5aa897c0938acaaee5f515 /pcap-bt-linux.c | |
parent | 666a4890f9d8dee0ac8affbeeab2a96b4cac4ec9 (diff) |
Bluetooth: fix non-blocking mode
Fix non-blocking mode with bt-linux and bt-monitor-linux. Previously
when fd was set to non-blocking mode and pcap_dispatch() was called
from application, it returned -1 with errno EAGAIN breaking the api
contract.
Fix is to handle errnos EAGAIN and EWOULDBLOCK so that 0 is returned.
Diffstat (limited to 'pcap-bt-linux.c')
-rw-r--r-- | pcap-bt-linux.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pcap-bt-linux.c b/pcap-bt-linux.c index 2969ff8d..8e70febc 100644 --- a/pcap-bt-linux.c +++ b/pcap-bt-linux.c @@ -341,6 +341,10 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char } while ((ret == -1) && (errno == EINTR)); if (ret < 0) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { + /* Nonblocking mode, no data */ + return 0; + } pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, errno, "Can't receive packet"); return -1; |