diff mbox series

[ovs-dev] reconnect.c: Don't transition back to ACTIVE when forced to RECONNECT.

Message ID 1553187315-107323-1-git-send-email-hzhou8@ebay.com
State Superseded
Headers show
Series [ovs-dev] reconnect.c: Don't transition back to ACTIVE when forced to RECONNECT. | expand

Commit Message

Han Zhou March 21, 2019, 4:55 p.m. UTC
From: Han Zhou <hzhou8@ebay.com>

Currently, whenever there is activity on the session, the FSM is
transitioned to ACTIVE. However, this causes reconnect_force_reconnect()
failed to work once there are traffic received from remote after
transition to RECONNECT, it will skip the reconnection phase and directly
go back to ACTIVE for the old session. This patch fixes it so that
when FSM is in RECONNECT state, it doesn't transition back to ACTIVE
directly.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 lib/reconnect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff March 22, 2019, 8:29 p.m. UTC | #1
On Thu, Mar 21, 2019 at 09:55:15AM -0700, Han Zhou wrote:
> From: Han Zhou <hzhou8@ebay.com>
> 
> Currently, whenever there is activity on the session, the FSM is
> transitioned to ACTIVE. However, this causes reconnect_force_reconnect()
> failed to work once there are traffic received from remote after
> transition to RECONNECT, it will skip the reconnection phase and directly
> go back to ACTIVE for the old session. This patch fixes it so that
> when FSM is in RECONNECT state, it doesn't transition back to ACTIVE
> directly.
> 
> Signed-off-by: Han Zhou <hzhou8@ebay.com>
> ---
>  lib/reconnect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/reconnect.c b/lib/reconnect.c
> index 0f21378..e2901ab 100644
> --- a/lib/reconnect.c
> +++ b/lib/reconnect.c
> @@ -495,7 +495,7 @@ reconnect_connect_failed(struct reconnect *fsm, long long int now, int error)
>  void
>  reconnect_activity(struct reconnect *fsm, long long int now)
>  {
> -    if (fsm->state != S_ACTIVE) {
> +    if (fsm->state != S_ACTIVE && fsm->state != S_RECONNECT) {
>          reconnect_transition__(fsm, now, S_ACTIVE);
>      }

I think that the only state where this is useful is S_IDLE.  Would
'fsm->state == S_IDLE' be a better test?
Han Zhou March 22, 2019, 8:31 p.m. UTC | #2
On Fri, Mar 22, 2019 at 1:29 PM Ben Pfaff <blp@ovn.org> wrote:
>
> On Thu, Mar 21, 2019 at 09:55:15AM -0700, Han Zhou wrote:
> > From: Han Zhou <hzhou8@ebay.com>
> >
> > Currently, whenever there is activity on the session, the FSM is
> > transitioned to ACTIVE. However, this causes reconnect_force_reconnect()
> > failed to work once there are traffic received from remote after
> > transition to RECONNECT, it will skip the reconnection phase and directly
> > go back to ACTIVE for the old session. This patch fixes it so that
> > when FSM is in RECONNECT state, it doesn't transition back to ACTIVE
> > directly.
> >
> > Signed-off-by: Han Zhou <hzhou8@ebay.com>
> > ---
> >  lib/reconnect.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/reconnect.c b/lib/reconnect.c
> > index 0f21378..e2901ab 100644
> > --- a/lib/reconnect.c
> > +++ b/lib/reconnect.c
> > @@ -495,7 +495,7 @@ reconnect_connect_failed(struct reconnect *fsm, long long int now, int error)
> >  void
> >  reconnect_activity(struct reconnect *fsm, long long int now)
> >  {
> > -    if (fsm->state != S_ACTIVE) {
> > +    if (fsm->state != S_ACTIVE && fsm->state != S_RECONNECT) {
> >          reconnect_transition__(fsm, now, S_ACTIVE);
> >      }
>
> I think that the only state where this is useful is S_IDLE.  Would
> 'fsm->state == S_IDLE' be a better test?

Agree! It will be more accurate. I will send v2.
diff mbox series

Patch

diff --git a/lib/reconnect.c b/lib/reconnect.c
index 0f21378..e2901ab 100644
--- a/lib/reconnect.c
+++ b/lib/reconnect.c
@@ -495,7 +495,7 @@  reconnect_connect_failed(struct reconnect *fsm, long long int now, int error)
 void
 reconnect_activity(struct reconnect *fsm, long long int now)
 {
-    if (fsm->state != S_ACTIVE) {
+    if (fsm->state != S_ACTIVE && fsm->state != S_RECONNECT) {
         reconnect_transition__(fsm, now, S_ACTIVE);
     }
     fsm->last_activity = now;