summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-05-07 16:59:59 -0400
committerAdam Jackson <ajax@redhat.com>2009-05-07 16:59:59 -0400
commit29f27b16dbe511a27a0e953b32913f9d9bf24f2d (patch)
treea0de32c1e117a7cd157b458fbfbb91c886ee63c0 /src
parent33b839e16fe681ba915658f824ceb1b252084ea4 (diff)
Use flockfile if available.
Not really a huge improvement, but we might as well.
Diffstat (limited to 'src')
-rw-r--r--src/maprules.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/maprules.c b/src/maprules.c
index cfc4d6d..b6d773c 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -137,6 +137,14 @@ InputLineAddChar(InputLine *line,int ch)
(int)((l)->line[(l)->num_line++]= (c)):\
InputLineAddChar(l,c))
+#ifdef HAVE_UNLOCKED_STDIO
+#undef getc
+#define getc(x) getc_unlocked(x)
+#else
+#define flockfile(x) do {} while (0)
+#define funlockfile(x) do {} while (0)
+#endif
+
static Bool
GetInputLine(FILE *file,InputLine *line,Bool checkbang)
{
@@ -144,6 +152,7 @@ int ch;
Bool endOfFile,spacePending,slashPending,inComment;
endOfFile= False;
+ flockfile(file);
while ((!endOfFile)&&(line->num_line==0)) {
spacePending= slashPending= inComment= False;
while (((ch=getc(file))!='\n')&&(ch!=EOF)) {
@@ -208,6 +217,7 @@ Bool endOfFile,spacePending,slashPending,inComment;
endOfFile= True;
/* else line->num_line++;*/
}
+ funlockfile(file);
if ((line->num_line==0)&&(endOfFile))
return False;
ADD_CHAR(line,'\0');