[Kde-pim] Review Request 113340: fix reading of mbox file when slowly filled by external program

Martin Koller kollix at aon.at
Fri Oct 18 21:24:38 BST 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/113340/
-----------------------------------------------------------

Review request for KDEPIM-Libraries.


Bugs: 324173
    http://bugs.kde.org/show_bug.cgi?id=324173


Repository: kdepimlibs


Description
-------

The mbox resource can watch for file changes.
When an external program fills the mbox file and this takes some time (e.g. 10 seconds, during which mails get added and added),
the file watcher triggers indirectly the method MBox::load(), which does as a first step d->initLoad( fileName ); (mainly to set the filename
so the following lock() call knows what the lockfile shall be).
But the bug is that the d->initLoad( fileName ) call also stores the current mbox filesize - which is still changing until the lock can be finally made.
(I'm talking about procmail lockfile). When the external program is finally done, the mbox filesize is larger than what the mbox resource
has stored in d->mInitialMboxFileSize

This patch stores the filesize AFTER the lock could be made.


Diffs
-----

  kmbox/mbox.cpp 3658bf6 
  kmbox/mbox_p.cpp b4e323b 

Diff: http://git.reviewboard.kde.org/r/113340/diff/


Testing
-------

The following shell script shows the problem (you also need a file "testmail" which contains a mail to be added).
E.g. make sure the mbox file is empty, the run the script. When the loop is done, kmail will tell you there are 5 new mails, but
only the first one shows subject, sender, etc.

#!/bin/bash

num=$RANDOM
i=0

LOCKFILE=~/airsync.mbox.lock
lockfile -l20 -r5 $LOCKFILE
if [ $? -ne 0 ]
then
  echo "locking error"
  exit
fi

while (( $i < 5 ))
do
  let num++
  let i++
  echo "sending mail" $num
  sed -e "s/<NUMBER>/$num/" testmail >> ~/airsync.mbox
  ls -l  ~/airsync.mbox*

  sleep 3
done

rm -f $LOCKFILE


Thanks,

Martin Koller

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list