diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-06-04 16:30:50 +0200 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-06-04 16:30:54 +0200 |
commit | 01656bf88c9d7a2d23d042874156b689388cdc46 (patch) | |
tree | ac3b70974825b7904160efc7ac2b521089d91580 | |
parent | 63e6314777f161fc71117424b8dd65df98fc6a6d (diff) | |
download | microcom-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.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -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; + } } } |