On Tue, Feb 26, 2002 at 03:04:27AM -0800, Craig Hughes wrote:
> FYI, your code example is not even close to concurrency-safe.  If one
> instance checks (-f $path) and finds no file, then context switches, and
> instance #2 performs the same check, then both instances will try to
> create a new file, and you'll probably end up with some weird mangled DB
> file.
> 
> >          if ( -f $path ) {
> >            tie %{$self->{accum}},"AnyDBM_File",$path, O_RDWR,   #open rw w/lock
> >                      (oct ($main->{conf}->{auto_whitelist_file_mode}) & 0666)
> >            or die "Cannot open existing auto_whitelist_path $path: $!\n";
> >            
> >          } else {
> >            tie %{$self->{accum}},"AnyDBM_File",$path, O_RDWR|O_CREAT,   #open rw 
>w/lock
> >                      (oct ($main->{conf}->{auto_whitelist_file_mode}) & 0666)
> >            or die "Cannot open auto_whitelist_path $path for creation: $!\n";
> >          }

Is there a reason you do a check for O_CREAT?  O_CREAT just says "create if
it doesn't already exist", it won't truncate the current data (that's
O_TRUNC).  I would elliminate this code and just have a single tie with
O_CREAT.

-- 
Randomly Generated Tagline:
"Besides, I wasn't envisioning building the full scale, "hurl flaming tar
 filled pottery at peasants over castle walls" type of trebuchet. More
 like the "hurl flaming jet puffed marshmallows at chipmunks over the
 picnic table" trebuchet. :-)"   - Timothy MacDonald

_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to