# HG changeset patch # User Mahlon E. Smith # Date 1320691386 28800 # Node ID e6a640ad2cc29b46ad5748e639507afdf203d98b # Parent 2706fc514dea0438888e1adb62c3eab7263b6573 Ensure that all output is flushed immediately. Fix free() bug for non-matching rules. When creating the rules cdb, make the tmpfile in the cwd instead of /tmp. Make regular expression matches case insensitive. diff -r 2706fc514dea -r e6a640ad2cc2 Makefile --- a/Makefile Sat Nov 05 12:52:29 2011 -0700 +++ b/Makefile Mon Nov 07 10:43:06 2011 -0800 @@ -93,7 +93,7 @@ ctags *.h *.c clobber: clean - rm -f parser.c volta.cdb ChangeLog tags + rm -f parser.c volta.db ChangeLog tags clean: -rm -f volta *_graph.* *.o *.prof* diff -r 2706fc514dea -r e6a640ad2cc2 db.c --- a/db.c Sat Nov 05 12:52:29 2011 -0700 +++ b/db.c Mon Nov 07 10:43:06 2011 -0800 @@ -88,7 +88,7 @@ /* open temporary file */ debug( 0, LOC, "Creating/updating database (%s) using rules in \"%s\"\n", v.dbname, txt ); - sprintf( tmpfile, "/tmp/volta-db-%d.tmp", getpid() ); + sprintf( tmpfile, "volta-db-%d.tmp", getpid() ); if ( (tmp_fd = open( tmpfile, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH )) == -1 ) { debug( 0, LOC, "Error writing temporary file: %s\n", strerror(errno) ); @@ -131,7 +131,7 @@ /* move cdb into place */ if ( (rename( tmpfile, v.dbname )) == -1 ) { - debug( 1, LOC, "Unable to move temp cdb into place: %s", strerror(errno) ); + debug( 0, LOC, "Unable to move temp cdb into place: %s", strerror(errno) ); return( 1 ); } @@ -182,7 +182,7 @@ free( val ); if ( rule != NULL ) { if ( check_rule( rule, p_request ) == 0 ) { - finish_parsed( rule ); + finish_parsed( rule ), rule = NULL; } else { break; diff -r 2706fc514dea -r e6a640ad2cc2 process.c --- a/process.c Sat Nov 05 12:52:29 2011 -0700 +++ b/process.c Mon Nov 07 10:43:06 2011 -0800 @@ -108,6 +108,7 @@ printf( "%s", rule->path ? rule->path : request->path ); printf("\n"); + fflush( stdout ); return; } @@ -134,7 +135,7 @@ } /* compile the regexp */ - if ( (re_rv = regcomp( &re, rule->path_re, REG_EXTENDED | REG_NOSUB )) != 0 ) { + if ( (re_rv = regcomp( &re, rule->path_re, REG_EXTENDED | REG_NOSUB | REG_ICASE )) != 0 ) { regerror( re_rv, &re, re_err, 128 ); debug( 4, LOC, "Invalid regex: \"%s\": %s\n", rule->path_re, re_err ); regfree( &re ); diff -r 2706fc514dea -r e6a640ad2cc2 util.c --- a/util.c Sat Nov 05 12:52:29 2011 -0700 +++ b/util.c Mon Nov 07 10:43:06 2011 -0800 @@ -75,6 +75,7 @@ PROG, timestamp, getpid(), level, file, line ); vfprintf( stderr, fmt, args ); va_end( args ); + fflush( stderr ); return; } @@ -88,6 +89,7 @@ { if ( v.debugmode >= 5 ) return; fprintf( stdout, "%s", str ); + fflush( stdout ); return; } @@ -164,6 +166,7 @@ v.timer.lines+1, (line_realloc == NULL ? strerror(errno) : "Line too large") ); free( line ), line = NULL; printf( "\n" ); + fflush( stdout ); } else { line = line_realloc;