[comp.sys.isis] patch to cl_token.c

ken@gvax.cs.cornell.edu (Ken Birman) (01/18/91)

I've fixed a fault-tolerance bug in the token tool, which was
handling the "pass on failure" flag incorrectly and jamming after
certain failure sequences.

First, a fix to the manual: the manual says to set this flag to
FALSE if you want the token to pass on failure (in t_request).
In fact, TRUE means pass on failures.  FALSE means don't (i.e. if
your own code will handle doing so)

Here's a patch script to get the tool to implement this flag.  The
old code was not passing on failure regardless of what you said to do:

*** /tmp/,RCSt1a15996   Thu Jan 17 16:55:11 1991
--- cl_token.c  Thu Jan 17 16:54:49 1991
***************
*** 315,321 ****

  static void ignore(mp)
    message *mp;
!   {}

  static void
  do_send_token(msg, gaddr, how, tp)
--- 315,322 ----

  static void ignore(mp)
    message *mp;
!   {
!   }

  static void
  do_send_token(msg, gaddr, how, tp)
***************
*** 322,340 ****
    message *msg;
    address *gaddr;
    int how;
!   register char *tp;
    {
          send_token(tp);
          cc_terminate("");
    }

  static void
! t_failed(tp)
    register token *tp;
    {
          if(tp->t_flag&T_PASS_ON_FAIL)
!             coord_cohort((message*)0, &(tp->t_gaddr),
!                          do_send_token, ignore, tp);
          else
             tp->t_flag |= T_FAIL;
    }
--- 323,342 ----
    message *msg;
    address *gaddr;
    int how;
!   register token *tp;
    {
+         tp->t_flag |= T_HOLD;
          send_token(tp);
          cc_terminate("");
    }

  static void
! t_failed(gaddr_p, paddr_p, event, tp)
    register token *tp;
+   register address *gaddr_p, *paddr_p;
    {
          if(tp->t_flag&T_PASS_ON_FAIL)
!             coord_cohort((message*)0, &tp->t_gaddr, do_send_token, ignore, tp)
;
          else
             tp->t_flag |= T_FAIL;
    }
***************
*** 360,367 ****
          if(tp->t_watch)
              pg_watch_cancel(tp->t_watch);
          if(pass_on_fail)
!             tp->t_watch = pg_watch(&tp->t_gaddr, &tp->t_holder, W_FAIL,
                                     t_failed, tp);
          else
              tp->t_watch = 0;
    }
--- 362,371 ----
          if(tp->t_watch)
              pg_watch_cancel(tp->t_watch);
          if(pass_on_fail)
!       {
!             tp->t_watch = pg_watch(&tp->t_gaddr, &tp->t_holder, W_LEAVE,
                                     t_failed, tp);
+       }
          else
              tp->t_watch = 0;
    }