Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Mail queue and file locking

Reply
Thread Tools

Mail queue and file locking

 
 
MadDogMcGee
Guest
Posts: n/a
 
      12-03-2004
Hi there, here's what I'm trying to do:

I'm on a Windows NT system, and want to monitor the Exchange mail queue for
new files. When there's a new file (an email) with certain keywords (i.e.
characteristic spam strings) I want to move the file to another folder so it
doesn't get sent.

Here's my approach, which is working but could probably be improved:

1. Poll the folder (waiting 1 second between polls)
2. If a file is "there", i.e. it has finished being copied across, and it is
less than 1 megabyte, scan it for keywords.
3. If the file has any keywords, move it to a different folder.
4. Goto 1.

To check if the file is copied across, I try to rename the file to itself.
If it's locked, Perl's rename function returns a 0 and if it's unlocked,
rename returns a 1.

I'm worried that using this approach of renaming files will lock them, and
prevent email from being moved out of the queue folder to be sent.

1. Is there a better way to detect new files than to poll the directory
every second?
2. What's the best way to check if a file is unlocked (i.e. fully copied
across)?
3. (Off topic) Any potential problems in scanning the NT Exchange 5.5 mail
queue folder and moving files out?


Thanks!





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program blocked in Queue.Queue.get and Queue.Queue.put Kris Python 0 01-04-2012 03:46 PM
increase in cpu usage on locking and locking the system sowmya.rangineni@gmail.com Computer Support 0 06-15-2007 12:06 PM
Application locking to support optimisitc locking ? Timasmith Java 4 11-01-2006 12:42 AM
Is Queue.Queue.queue.clear() thread-safe? Russell Warren Python 4 06-27-2006 03:03 PM
locking an XML file...will it create a queue? darrel ASP .Net 8 04-05-2006 09:33 PM



Advertisments