Tags:
create new tag
, view all tags
ALERT! NOTE: This add-on is obsoleted and repalced by the MailInContrib

Comments for the MailInAddOn

usage

For instructions about where to install it, please see MailInAddOn

coding

The way locking is done is open to races:


   my $lockfilename   = 'retry.lock';
   my $lockfile      = RETRYDIRECTORY.$lockfilename;
   my $numoffiles      = 0;
   my $successes      = 0;

   #check to see it the directory exists
   if (! -e RETRYDIRECTORY)
   {
      return NODIRERROR;
   }
   #check to see if the lockfile exists
   elsif (-e "$lockfile")
   {
      return DIRLOCKERROR;
   }
   else
   {
      #create the lock file
      open(LOCK, ">$lockfile");
      print LOCK "This is a lock file. Please do not delete $lockfile";
      close(LOCK);


Someone else could create the lock file after you checked for its existence. Does Windows support flock? I read in the Perl Cookbook, that this is the recommended approach except when working over NFS.

-- FrankHartmann - 13 May 2002

I agree that the mechanism we used can be usefully improved. Please feel free to submit code changes!

philosophy

TWiki itself gives the user a Topic is locked by error message if two users want to change the same thing at the same time. This has two effects:

  • it makes the retry handling very easy
  • it ensures that the second user can read the contribution of the first user before and can react to it.

I think you attempt to install automatic retry handling, which disables the second point. Perhaps a answering email message 'topic is locked by someone else' would be better?

-- FrankHartmann - 13 May 2002

I disagree. We wanted to get people to CC: Twiki and have TWiki submit the addition as soon as possible. We had a lot of off-line users who would batch update TWiki whilst on the road with their laptops so we particularly wanted to not involve the user more than necessary.

-- MartinCleaver - 20 Jan 2002

Frank.

It all depends on the architecture you use. We never used POP at work, we used LotusNotes. However, I've just hacked together a file pop2twiki.pl (see MailInAddOnDev). Relies On Net::Pop3, standard part of 5.7.3 Perl dist.

If you want to play around with it. The username lookup stuff is broken. Workaround:

  1. register a user 'MailInUser'
  2. make the following code change:
bash-2.04$ diff MailIn.pm*
208c208
<     my $loginName = 'MailInUser'; #deriveLoginNameFromEmailAddress($fromAddress);
---
>     my $loginName = deriveLoginNameFromEmailAddress($fromAddress);

Caveats:

  • I did not do the coding for MailIn.pm, there are several things that I would want to change.

I would help more except 1) I pay per hour for internet access as I am backpacking in Oz. 2) I am studying for an exam at the mo.

-- MartinCleaver - 19 May 2002

Changes needed:

  • Structure of code
  • Make it a real class
  • Do locking such that there is no race condition.

-- MartinCleaver - 19 May 2002

Anybody got that running with AthensRelease on Solaris? I'm too lazy to figure it out myself:

> cat mailin
#!/usr/bin/perl -w

use lib (".");        use MailIn;

TWiki::MailIn::send(
'From: me@localhost
To: twiki@localhost
Subject: Test.MailInInterface

text body
');

> ./mailin
Useless use of scalar ref constructor in void context at MailIn.pm line 127.
Useless use of scalar ref constructor in void context at MailIn.pm line 517.
Name "TWiki::MailIn::MESS" used only once: possible typo at MailIn.pm line 195.
Use of uninitialized value at MailIn.pm line 84.
Use of uninitialized value at MailIn.pm line 373.
Use of uninitialized value at ../lib/TWiki/Store.pm line 66.
Use of uninitialized value at MailIn.pm line 263.
Use of uninitialized value at MailIn.pm line 396.
Use of uninitialized value at MailIn.pm line 396.
Can't use an undefined value as a symbol reference at MailIn.pm line 400.

> perl --version

This is perl, version 5.005_03 built for sun4-solaris

-- PeterKlausner - 23 Aug 2002

First, I found I needed Perl 5.6 because some of the required libraries are not in 5.005_03. (Also, I am using a POP3 account for the email, so my mailin script needed POP3 libraries).

Second, the MailIn.pm code as provided needed a fair amount of work to make it run. Perhaps it ran for somebody else, but I could not see how. It may be because I am Perl-challenged. In any event, I was able to hack a version that sort of works, without really knowing what I was doing. I will feed this back to TWiki.org once it does more of what I need from it. Right now it is languishing, and far from ready for the public.

So the MailInAddOn is not currently a plug and play extension by any means.

-- DaveBoulton - 24 Aug 2002

Perl 5.6? Requires custom hacking? Ouch.

-- GrantBow - 10 Jan 2003

I've discovered it doesn't work with the 01-Feb-2003 Release (Beijing) without tweaks to the code. I modified MailToTWikiAddOn instead...

-- PeterMorch - 14 May 2003

the traditional unix way (before flock existed) was to use the atomic operation:

   ln _existing_file_ _lock_file_
which has the property of in one atomic operation create the lock_file if it can or return an error. (with the advent of symbolic links "ln -s" the source file do not even need to exist). This works across NFS. maybe some equivalent call can be done in windows (an open file with creatre mode, returning an error if it already exists?)

-- ColasNahaboo - 14 May 2003

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2006-04-06 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.