mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-07 09:58:31 +00:00
reds-stream: Simplify error logic
Handling read returning 0 (usually end of connection/pipe) is the same of handling an error (read result -1) with errno == 0 so merge the two paths to reuse code and simplify. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
e4bb431191
commit
8cef0a4e8b
@ -499,28 +499,21 @@ static void async_read_handler(G_GNUC_UNUSED int fd,
|
||||
spice_assert(n > 0);
|
||||
n = reds_stream_read(stream, async->now, n);
|
||||
if (n <= 0) {
|
||||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EAGAIN:
|
||||
if (!stream->watch) {
|
||||
stream->watch = reds_core_watch_add(reds, stream->socket,
|
||||
SPICE_WATCH_EVENT_READ,
|
||||
async_read_handler, async);
|
||||
}
|
||||
return;
|
||||
case EINTR:
|
||||
break;
|
||||
default:
|
||||
async_read_clear_handlers(async);
|
||||
if (async->error) {
|
||||
async->error(async->opaque, errno);
|
||||
}
|
||||
return;
|
||||
int err = n < 0 ? errno: 0;
|
||||
switch (err) {
|
||||
case EAGAIN:
|
||||
if (!stream->watch) {
|
||||
stream->watch = reds_core_watch_add(reds, stream->socket,
|
||||
SPICE_WATCH_EVENT_READ,
|
||||
async_read_handler, async);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
case EINTR:
|
||||
break;
|
||||
default:
|
||||
async_read_clear_handlers(async);
|
||||
if (async->error) {
|
||||
async->error(async->opaque, 0);
|
||||
async->error(async->opaque, err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user