procmail
[Top] [All Lists]

Re: Lock files - confused

1999-12-20 12:11:52
Steve Youngs asked,

| Lock files, basically, they confuse the fsck out of me. :-(
| 
| Can someone enlighten me as to:
| 
| Why I need them?

To keep two concurrent processes from trying to modify the same file at the
same time and generally making a mess of it; for example, the one that writes
last can clobber the other's changes, or they can both be appending at the
same time and mixing their text together.

| When do I need them?

Whenever the action line of a recipe (or occasionally a condition line that
runs a program) modifies a file, or whenever for any other reason you want
to be sure that some code is not attempted on two or more messages at the
same time, but rather you want each one to wait for its turn.

| What are the different types?

Global and local.  When we speak of a "regional" lockfile, we mean a global
one of limited scope.

A local lockfile is set by using a second colon on the flag line of a recipe;
if the action line does not give procmail a way to infer a name for the local
lockfile (so you have to supply a name yourself), or if you want procmail to
use a different name from the one it would infer, you can specify a name for
the local lockfile to the right of the second colon.  When the action is com-
pleted, procmail will remove the local lockfile.

A global or regional lockfile is set by assigning a value to the LOCKFILE
variable.  Regional lockfiles are removed by unsetting the LOCKFILE variable;
global lockfiles (and any remaining regional lockfiles) are removed by proc-
mail when it exits.

| When do I use the different types?

You use a local one whenever it will do the job; regional when local will not
work; global only when neither local nor regional will do it.

| What can go wrong if I either don't use them or use the wrong type?

You can get mangled mail ... the text of two messages mixed together, for
example, instead of one message following the other in the folder.

<Prev in Thread] Current Thread [Next in Thread>