mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 20:26:36 +00:00
zebra,fpm: fix input handling
Two important fixes: * `stream_read_try` does a dirty trick and converts the `-1` return to `-2` when errno is `EAGAIN`, `EWOULDBLOCK` or `EINTR`. * Don't enable reads until the connection is complete. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
a203232464
commit
e1afb97fdd
@ -475,6 +475,13 @@ static int fpm_read(struct thread *t)
|
|||||||
/* Let's ignore the input at the moment. */
|
/* Let's ignore the input at the moment. */
|
||||||
rv = stream_read_try(fnc->ibuf, fnc->socket,
|
rv = stream_read_try(fnc->ibuf, fnc->socket,
|
||||||
STREAM_WRITEABLE(fnc->ibuf));
|
STREAM_WRITEABLE(fnc->ibuf));
|
||||||
|
/* We've got an interruption. */
|
||||||
|
if (rv == -2) {
|
||||||
|
/* Schedule next read. */
|
||||||
|
thread_add_read(fnc->fthread->master, fpm_read, fnc,
|
||||||
|
fnc->socket, &fnc->t_read);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
atomic_fetch_add_explicit(&fnc->counters.connection_closes, 1,
|
atomic_fetch_add_explicit(&fnc->counters.connection_closes, 1,
|
||||||
memory_order_relaxed);
|
memory_order_relaxed);
|
||||||
@ -486,10 +493,6 @@ static int fpm_read(struct thread *t)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK
|
|
||||||
|| errno == EINTR)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
atomic_fetch_add_explicit(&fnc->counters.connection_errors, 1,
|
atomic_fetch_add_explicit(&fnc->counters.connection_errors, 1,
|
||||||
memory_order_relaxed);
|
memory_order_relaxed);
|
||||||
zlog_warn("%s: connection failure: %s", __func__,
|
zlog_warn("%s: connection failure: %s", __func__,
|
||||||
@ -541,6 +544,10 @@ static int fpm_write(struct thread *t)
|
|||||||
|
|
||||||
fnc->connecting = false;
|
fnc->connecting = false;
|
||||||
|
|
||||||
|
/* Permit receiving messages now. */
|
||||||
|
thread_add_read(fnc->fthread->master, fpm_read, fnc,
|
||||||
|
fnc->socket, &fnc->t_read);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Walk the route tables to send old information before starting
|
* Walk the route tables to send old information before starting
|
||||||
* to send updated information.
|
* to send updated information.
|
||||||
@ -672,6 +679,7 @@ static int fpm_connect(struct thread *t)
|
|||||||
|
|
||||||
fnc->connecting = (errno == EINPROGRESS);
|
fnc->connecting = (errno == EINPROGRESS);
|
||||||
fnc->socket = sock;
|
fnc->socket = sock;
|
||||||
|
if (!fnc->connecting)
|
||||||
thread_add_read(fnc->fthread->master, fpm_read, fnc, sock,
|
thread_add_read(fnc->fthread->master, fpm_read, fnc, sock,
|
||||||
&fnc->t_read);
|
&fnc->t_read);
|
||||||
thread_add_write(fnc->fthread->master, fpm_write, fnc, sock,
|
thread_add_write(fnc->fthread->master, fpm_write, fnc, sock,
|
||||||
|
Loading…
Reference in New Issue
Block a user