Tasks cannot be reordered.
Lets look at something like this
- Start processing/new transaction
- Get message from spool(requires contacting remote spool)
- verify signature (requires contacting remote keyservers)
- uncompress/convert/split
- Send required files(remote...)
- Request additional parts(remote..)
- End transaction
Or, better yet, think of pop3 client,
- Authenticate
- Get list of new mails
- Get mail body (repeat)
...
Imagine what happens when you implement it like this:
auth();
@uidls=getuidls();
foreach $uidl (@uidls) {
fork || getmail($uidl);
};
getting back to my original problem, you can easily put timeout protection inside getuidl and getmail, but what you created is either instant DOS against your provider, and yourself (try that code with 1000s of mails to download..).
Not to mention that now you have to devise a clever way for generating for example unique filename for every mail you're downloading and few similar headaches.
Of course if you're trying to write reasonable code, and use just one connection for downloading those mails, you need to devise a clever scheme of locking and passing socket fd around to your children etc... |