summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2023-06-04 16:30:50 +0200
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2023-06-04 16:30:54 +0200
commit01656bf88c9d7a2d23d042874156b689388cdc46 (patch)
treeac3b70974825b7904160efc7ac2b521089d91580
parent63e6314777f161fc71117424b8dd65df98fc6a6d (diff)
downloadmicrocom-01656bf88c9d7a2d23d042874156b689388cdc46.tar.gz
microcom-01656bf88c9d7a2d23d042874156b689388cdc46.tar.xz
mux: Ignore .read() returning errors EAGAIN and EWOULDBLOCK
For the telnet backend the fd might be ready to read, but there is only out-of-band data available. Up to now this out-of-band data is handled in mux.c, but to prepare handling all the telnet specific stuff in telnet.c, there must be a way to let telnet's read function handle only out-of-band data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r--mux.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/mux.c b/mux.c
index b7535b8..9dc684c 100644
--- a/mux.c
+++ b/mux.c
@@ -449,19 +449,20 @@ int mux_loop(struct ios_ops *ios)
/* pf has characters for us */
len = ios->read(ios, buf, BUFSIZE);
if (len < 0) {
- ret = -errno;
- fprintf(stderr, "%s\n", strerror(-ret));
- return ret;
- }
- if (len == 0) {
+ if (errno != EAGAIN && errno != EWOULDBLOCK) {
+ ret = -errno;
+ fprintf(stderr, "%s\n", strerror(-ret));
+ return ret;
+ }
+ } else if (len == 0) {
fprintf(stderr, "Got EOF from port\n");
return -EINVAL;
- }
-
- i = handle_receive_buf(ios, buf, len);
- if (i < 0) {
- fprintf(stderr, "%s\n", strerror(-i));
- return i;
+ } else {
+ i = handle_receive_buf(ios, buf, len);
+ if (i < 0) {
+ fprintf(stderr, "%s\n", strerror(-i));
+ return i;
+ }
}
}