fix deadlock when trying to create a module with the same name as a

predicate (for now, just don't lock modules). obs Paulo Moura.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1869 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2007-04-18 23:01:16 +00:00
parent ee03654060
commit dc3b7079f4
3 changed files with 25 additions and 13 deletions

View File

@@ -33,17 +33,18 @@ FetchModuleEntry(Atom at)
Prop p0;
AtomEntry *ae = RepAtom(at);
WRITE_LOCK(ae->ARWLock);
READ_LOCK(ae->ARWLock);
p0 = ae->PropsOfAE;
while (p0) {
ModEntry *me = RepModProp(p0);
if ( me->KindOfPE == ModProperty
) {
WRITE_UNLOCK(ae->ARWLock);
READ_UNLOCK(ae->ARWLock);
return me;
}
p0 = me->NextOfPE;
}
READ_UNLOCK(ae->ARWLock);
return NULL;
}
@@ -55,13 +56,11 @@ GetModuleEntry(Atom at)
AtomEntry *ae = RepAtom(at);
ModEntry *new;
WRITE_LOCK(ae->ARWLock);
p0 = ae->PropsOfAE;
while (p0) {
ModEntry *me = RepModProp(p0);
if ( me->KindOfPE == ModProperty
) {
WRITE_UNLOCK(ae->ARWLock);
return me;
}
p0 = me->NextOfPE;
@@ -75,7 +74,6 @@ GetModuleEntry(Atom at)
new->AtomOfME = ae;
new->NextOfPE = ae->PropsOfAE;
ae->PropsOfAE = AbsModProp(new);
WRITE_UNLOCK(ae->ARWLock);
return new;
}
@@ -105,12 +103,14 @@ static ModEntry *
LookupModule(Term a)
{
Atom at;
ModEntry *me;
/* prolog module */
if (a == 0)
return GetModuleEntry(AtomOfTerm(TermProlog));
at = AtomOfTerm(a);
return GetModuleEntry(at);
me = GetModuleEntry(at);
return me;
}
Term
@@ -136,9 +136,10 @@ Yap_NewModulePred(Term mod, struct pred_entry *ap)
if (!(me = LookupModule(mod)))
return;
/* LOCK THIS */
WRITE_LOCK(me->ModRWLock);
ap->NextPredOfModule = me->PredForME;
me->PredForME = ap;
WRITE_UNLOCK(me->ModRWLock);
}
static Int
@@ -162,7 +163,7 @@ p_current_module(void)
CurrentModule = t;
LookupModule(CurrentModule);
}
return (TRUE);
return TRUE;
}
static Int