Add and use internal (lockless) version of rpmDefineMacro()
- rpmLoadMacroFile() already grabs the (theoretical) lock on entry so we shouldn't try to grab it again, use the new lockless defineMacro() version for the purpose. - rpmDefineMacro() is now just a simple lock-wrapper around defineMacro()
This commit is contained in:
parent
1036601e3e
commit
bfda1b6013
|
@ -1396,6 +1396,17 @@ static void popMacro(rpmMacroContext mc, const char * n)
|
||||||
free(me);
|
free(me);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
||||||
|
{
|
||||||
|
MacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||||
|
|
||||||
|
/* XXX just enough to get by */
|
||||||
|
mb->mc = mc;
|
||||||
|
(void) doDefine(mb, macro, level, 0);
|
||||||
|
_free(mb);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* External interfaces */
|
/* External interfaces */
|
||||||
|
|
||||||
int expandMacros(void * spec, rpmMacroContext mc, char * sbuf, size_t slen)
|
int expandMacros(void * spec, rpmMacroContext mc, char * sbuf, size_t slen)
|
||||||
|
@ -1453,13 +1464,9 @@ void delMacro(rpmMacroContext mc, const char * n)
|
||||||
int
|
int
|
||||||
rpmDefineMacro(rpmMacroContext mc, const char * macro, int level)
|
rpmDefineMacro(rpmMacroContext mc, const char * macro, int level)
|
||||||
{
|
{
|
||||||
MacroBuf mb = xcalloc(1, sizeof(*mb));
|
mc = rpmmctxAcquire(mc);
|
||||||
|
(void) defineMacro(mc, macro, level);
|
||||||
/* XXX just enough to get by */
|
rpmmctxRelease(mc);
|
||||||
mb->mc = rpmmctxAcquire(mc);
|
|
||||||
(void) doDefine(mb, macro, level, 0);
|
|
||||||
rpmmctxRelease(mb->mc);
|
|
||||||
_free(mb);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,7 +1514,7 @@ rpmLoadMacroFile(rpmMacroContext mc, const char * fn)
|
||||||
if (c != '%')
|
if (c != '%')
|
||||||
continue;
|
continue;
|
||||||
n++; /* skip % */
|
n++; /* skip % */
|
||||||
rc = rpmDefineMacro(mc, n, RMIL_MACROFILES);
|
rc = defineMacro(mc, n, RMIL_MACROFILES);
|
||||||
}
|
}
|
||||||
rpmmctxRelease(mc);
|
rpmmctxRelease(mc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue