ING_DB
This commit is contained in:
parent
71cf2e46a1
commit
c698899c41
|
|
@ -0,0 +1,157 @@
|
||||||
|
# include "AA_liba.h"
|
||||||
|
|
||||||
|
static int AA_2_TA;
|
||||||
|
|
||||||
|
AAlock(d, rel, mod)
|
||||||
|
register DESCXX *d;
|
||||||
|
register char *rel;
|
||||||
|
register int mod;
|
||||||
|
{
|
||||||
|
# ifdef AMX_TRACE
|
||||||
|
AAtTfp(14, 0,
|
||||||
|
# ifdef MSDOS
|
||||||
|
"use\t\t`%.10s' (%d) mod %d\n",
|
||||||
|
# else
|
||||||
|
"use\t\t`%.14s' (%d) mod %d\n",
|
||||||
|
# endif
|
||||||
|
rel, d->xx_locks, mod);
|
||||||
|
# endif
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
if (!d)
|
||||||
|
|
||||||
|
if (AA_NOLOCKS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (AA_LOCKS)
|
||||||
|
AAerror(107, "TA-begin");
|
||||||
|
|
||||||
|
if (mod < 0)
|
||||||
|
{
|
||||||
|
if (AA_2_TA)
|
||||||
|
goto concur;
|
||||||
|
mod = -mod;
|
||||||
|
AA_2_TA++;
|
||||||
|
}
|
||||||
|
else if (!AA_2_TA)
|
||||||
|
{
|
||||||
|
concur:
|
||||||
|
AAerror(107, "second TA");
|
||||||
|
}
|
||||||
|
|
||||||
|
do AArel_lock(d, mod); while (d = d->xx_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static AArel_lock(d, mod)
|
||||||
|
register DESCXX *d;
|
||||||
|
register int mod;
|
||||||
|
{
|
||||||
|
# ifdef AMX_TRACE
|
||||||
|
AAtTfp(31, 0,
|
||||||
|
# ifdef MSDOS
|
||||||
|
"lock\t\t`%.10s' (%d) mod %d\n",
|
||||||
|
# else
|
||||||
|
"lock\t\t`%.14s' (%d) mod %d\n",
|
||||||
|
# endif
|
||||||
|
d->xx_desc.reldum.relid, d->xx_locks, mod);
|
||||||
|
# endif
|
||||||
|
AA = errno = 0;
|
||||||
|
|
||||||
|
if (d->xx_ta)
|
||||||
|
AAerror(17, d->xx_desc.reldum.relid);
|
||||||
|
|
||||||
|
if ((d->xx_excl = mod) == M_EXCL)
|
||||||
|
{
|
||||||
|
/* restore relation of descriptor d to read/write mode */
|
||||||
|
d->xx_desc.relopn = RELWOPEN(d->xx_desc.relfp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AA_TA)
|
||||||
|
{
|
||||||
|
d->xx_ta = AA_TA->xx_ta;
|
||||||
|
AA_TA->xx_ta = d;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
d->xx_ta = d;
|
||||||
|
AA_TA = d->xx_ta;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
# ifdef AMX_TRACE
|
||||||
|
AAtTfp(31, 1,
|
||||||
|
# ifdef MSDOS
|
||||||
|
".... rtn (%d)\t`%.10s'\n",
|
||||||
|
# else
|
||||||
|
".... rtn (%d)\t`%.14s'\n",
|
||||||
|
# endif
|
||||||
|
d->xx_excl, d->xx_desc.reldum.relid);
|
||||||
|
# endif
|
||||||
|
if (AAsetrll(A_RTN, d->xx_desc.reltid, d->xx_excl) < 0)
|
||||||
|
{
|
||||||
|
/* the lock request fails */
|
||||||
|
AAunlock(0);
|
||||||
|
/* wait on problem lock */
|
||||||
|
# ifdef AMX_TRACE
|
||||||
|
AAtTfp(31, 2,
|
||||||
|
# ifdef MSDOS
|
||||||
|
".... slp (%d)\t`%.10s'\n",
|
||||||
|
# else
|
||||||
|
".... slp (%d)\t`%.14s'\n",
|
||||||
|
# endif
|
||||||
|
d->xx_excl, d->xx_desc.reldum.relid);
|
||||||
|
# endif
|
||||||
|
if (AAsetrll(A_SLP, d->xx_desc.reltid, AA = d->xx_excl) < 0)
|
||||||
|
AAerror(17, d->xx_desc.reldum.relid);
|
||||||
|
AA_TA = d;
|
||||||
|
}
|
||||||
|
d->xx_locks++;
|
||||||
|
} while ((d = d->xx_ta) != AA_TA);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AAunlock(really)
|
||||||
|
register int really;
|
||||||
|
{
|
||||||
|
register DESCXX *next;
|
||||||
|
register DESCXX *d;
|
||||||
|
|
||||||
|
# ifdef AMX_TRACE
|
||||||
|
AAtTfp(15, 0, "commit\t\t(%d)\n", really);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
if (AA_NOLOCKS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(next = AA_TA))
|
||||||
|
AAerror(107, "TA-end");
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
d = next;
|
||||||
|
next = d->xx_ta;
|
||||||
|
|
||||||
|
if (really)
|
||||||
|
{
|
||||||
|
d->xx_excl = 0;
|
||||||
|
d->xx_ta = (DESCXX *) 0;
|
||||||
|
AAnoclose(d);
|
||||||
|
/* make believe relation is read only */
|
||||||
|
/* for concurrency that means, */
|
||||||
|
/* readed pages are not locked */
|
||||||
|
if (!bitset(S_CATALOG, d->xx_desc.reldum.relstat))
|
||||||
|
d->xx_desc.relopn = RELROPEN(d->xx_desc.relfp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((AA = d->xx_locks) && AAunlrl(d->xx_desc.reltid) < 0)
|
||||||
|
AAerror(18, d->xx_desc.reldum.relid);
|
||||||
|
d->xx_locks = 0;
|
||||||
|
} while (next != AA_TA);
|
||||||
|
|
||||||
|
if (really)
|
||||||
|
{
|
||||||
|
AA_TA = (DESCXX *) 0;
|
||||||
|
AA_2_TA = 0;
|
||||||
|
AAdaemon = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue