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

Defined functions

setpgl defined in line 9; used 1 times
unlpg defined in line 37; used 1 times

Defined variables

Lock defined in line 5; used 13 times
Last modified: 1995-02-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2144
Valid CSS Valid XHTML 1.0 Strict