Annotation of 42BSD/ingres/source/iutil/rub.c, revision 1.1

1.1     ! root        1: # include      <useful.h>
        !             2: # include      <signal.h>
        !             3: # include      <sccs.h>
        !             4: 
        !             5: SCCSID(@(#)rub.c       7.1     2/5/81)
        !             6: 
        !             7: /*
        !             8: **  RUB -- handle interrupt signals
        !             9: **
        !            10: **     This routine arranges to handle the interrupt signal
        !            11: **     on behalf of the CM.  It sends SYNC blocks to everyone
        !            12: **     who ought to get them, and arranges to ignore all
        !            13: **     blocks except SYNC (and RESET) blocks from everyone
        !            14: **     who will be sending one.  It also calls all of the
        !            15: **     interrupt functions for all active modules.  It does
        !            16: **     this after writing all of the sync blocks, so an
        !            17: **     interrupt function can safely issue a query if it
        !            18: **     wants.  It then does a non-local goto to the top of
        !            19: **     the main loop.
        !            20: **
        !            21: **     Parameters:
        !            22: **             none
        !            23: **
        !            24: **     Returns:
        !            25: **             non-local
        !            26: **
        !            27: **     Side Effects:
        !            28: **             Proc_name gets set to the CM name.
        !            29: **             Interrupt functions for all active modules
        !            30: **                     are invoked.
        !            31: **             The 'Syncs' vector is updated appropriately.
        !            32: **             SYNC blocks are sent to all adjacent processes.
        !            33: **
        !            34: **     Called By:
        !            35: **             System, via 'signal' (section 2).
        !            36: **
        !            37: **     Trace Flags:
        !            38: **             none
        !            39: */
        !            40: 
        !            41: int    RubLevel;       /* depth of ruboff calls, -1 if off */
        !            42: char   *RubWhy;        /* why are interrupts disabled */
        !            43: int    RubGot;         /* set if we have an unprocessed interrupt */
        !            44: 
        !            45: rubcatch()
        !            46: {
        !            47:        /* ignore interrupts while we are processing */
        !            48:        signal(SIGINT, SIG_IGN);
        !            49: 
        !            50:        /* find out if we are allowing interrupts */
        !            51:        if (RubLevel < 0)
        !            52:                syserr("bad SIGINT");
        !            53:        else if (RubLevel > 0)
        !            54:        {
        !            55:                /* save interrupt for later processing */
        !            56:                RubGot++;
        !            57:                if (RubWhy != NULL)
        !            58:                        printf("Rubout locked out (%s in progress)\n", RubWhy);
        !            59:        }
        !            60:        else
        !            61:        {
        !            62:                /* do other processing (either from ctlmod or standalones) */
        !            63:                rubproc();
        !            64:                syserr("rubcatch: rubproc");
        !            65:        }
        !            66: }
        !            67: /*
        !            68: **  TURN RUBOUTS OFF
        !            69: **
        !            70: **     Further rubouts will be caught by rubsave.
        !            71: **     The parameter should be the name of the processor which
        !            72: **     insists that rubouts do not occur.
        !            73: */
        !            74: 
        !            75: ruboff(why)
        !            76: char   *why;
        !            77: {
        !            78:        /* check to see if this should be ignored */
        !            79:        if (RubLevel < 0 || RubLevel++ > 0)
        !            80:                return;
        !            81: 
        !            82:        /* set up to ignore interrupts */
        !            83:        RubGot = 0;
        !            84:        RubWhy = why;
        !            85: }
        !            86: /*
        !            87: **  TURN RUBOUTS BACK ON
        !            88: **
        !            89: **     Rubout processing is restored to the norm (calling rubcatch).
        !            90: **     If any rubouts have occured while disabled, they are processed
        !            91: **     now.
        !            92: */
        !            93: 
        !            94: rubon()
        !            95: {
        !            96:        /* check to see if we should leave as-is */
        !            97:        if (RubLevel < 0 || --RubLevel > 0)
        !            98:                return;
        !            99: 
        !           100:        /* process any old interrupts */
        !           101:        if (RubGot > 0)
        !           102:                rubcatch();
        !           103: 
        !           104:        /* reset state */
        !           105:        RubWhy = NULL;
        !           106: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.