procmail
[Top] [All Lists]

Re: Counting mail messages, further

1998-05-18 13:44:20
I suggested to Bryan Albright,

|   :0
|   * conditions
|   {
|    LOCKFILE=file.lock # regional lockfile inside braces -- trust me
|
|    INCLUDERC=file # assigns $COUNT without a cat or a write
|
|    :0
|    * $ ${COUNT:-0}^0
|    * 1^0
|    { NEWCOUNT = $= }
|
|    :0chi
|    | echo "COUNT=$NEWCOUNT" > file
|
|    LOCKFILE # release regional lock
|   }

Come to think of it, you could do the same thing in a clone:

    :0c:file.lock
    * conditions
    {
     INCLUDERC=file # assigns $COUNT without a cat or a write

     :0
     * $ ${COUNT:-0}^0
     * 1^0
     { NEWCOUNT = $= }

     :0hi
     | echo "COUNT=$NEWCOUNT" > file

     HOST # in case of fall-through (highly unlikely with i and no w)
    }

That should fairly safely serialize the updates to the counter.

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