1: # include   <ingres.h>
   2: # include   <access.h>
   3: # include   <lock.h>
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)pglocks.c	8.1	12/31/84)
   7: 
   8: struct lockreq  Lock;
   9: /*
  10:  *	setpgl- sets a lock for the access buffer
  11:  */
  12: setpgl(buf)
  13: struct  accbuf  *buf;
  14: {
  15:     register struct accbuf  *b;
  16:     register int        i;
  17:     auto    int ret_val;
  18: 
  19: #	ifdef xATR1
  20:     if ( tTf(28,2) )
  21:     {
  22:         printf(" setpgl pg=%ld rel", buf->thispage);
  23:         dumptid(&buf->rel_tupid);
  24:     }
  25: #	endif
  26:     if (Alockdes < 0)
  27:         return(1);
  28:     b = buf;
  29:     Lock.lract = A_SLP; /* wait for lock */
  30:     Lock.lrtype = T_PAGE;   /* page lock */
  31:     Lock.lrmod = M_EXCL;    /* exclusive lock */
  32:     bmove(&b->rel_tupid, Lock.lrel, 4); /* copy relation id */
  33:     bmove(&b->thispage, Lock.lpage, 4); /* copy page id */
  34:     i = write(Alockdes,  &Lock,  KEYSIZE + 3);
  35:     read(Alockdes, &ret_val, sizeof (int));
  36:     b->bufstatus |= BUF_LOCKED;
  37:     return (ret_val);
  38: }
  39: /*
  40:  *	unlpg- releases a page lock
  41:  */
  42: unlpg(buf)
  43: struct  accbuf  *buf;
  44: {
  45:     register struct accbuf  *b;
  46:     register int        i;
  47:     auto    int ret_val;
  48: 
  49: #	ifdef xATR1
  50:     if (tTf(28, 3))
  51:     {
  52:         printf(" unlpg page %ld rel", buf->thispage);
  53:         dumptid(&buf->rel_tupid);
  54:     }
  55: #	endif
  56:     if (Alockdes < 0)
  57:         return(1);
  58:     b = buf;
  59:     Lock.lract = A_RLS1;
  60:     bmove(&b->rel_tupid, Lock.lrel, 4); /* copy relation id */
  61:     Lock.lrtype = T_PAGE;   /* page lock */
  62:     bmove(&b->thispage, Lock.lpage, 4); /* copy page id */
  63:     b->bufstatus &= ~BUF_LOCKED;
  64:     i = write(Alockdes,  &Lock,  KEYSIZE + 3);
  65:     read(Alockdes, &ret_val, sizeof (int));
  66:     return (ret_val);
  67: }
  68: /*
  69:  *	unlall - release all locks held by this process
  70:  */
  71: unlall()
  72: {
  73:     register int    i;
  74:     auto    int ret_val;
  75: 
  76: 
  77: #	ifdef xATR1
  78:     if (tTf(28, 6))
  79:         printf(" unlall\n");
  80: #	endif
  81: 
  82:     Acclock = TRUE; /* reset page lock flag just in case */
  83:     if (Alockdes < 0)
  84:         return(1);
  85:     Lock.lract = A_RLSA;
  86:     i = write(Alockdes, &Lock, KEYSIZE + 3);
  87:     read(Alockdes, &ret_val, sizeof (int));
  88:     return (ret_val);
  89: }

Defined functions

setpgl defined in line 12; used 1 times
unlall defined in line 71; never used
unlpg defined in line 42; used 1 times

Defined variables

Lock defined in line 8; used 13 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1063
Valid CSS Valid XHTML 1.0 Strict