From 29f27b16dbe511a27a0e953b32913f9d9bf24f2d Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 May 2009 16:59:59 -0400 Subject: Use flockfile if available. Not really a huge improvement, but we might as well. --- src/maprules.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') 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'); -- cgit v1.2.1