You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Rauno Palosaari <ra...@rauno.com> on 2001/10/23 10:34:02 UTC

James and multiple incoming mail.

Hi guys and dolls.

There is a problem with multiple incoming SMTP messages to James (and a 
workaround).
The problem is that a thread receiving the DATA part from a client will 
block other clients DATA or QUITs.

To reproduce it:
Start 2 telnet sessions to James (telnet 127.0.0.1 25)
Client 1 sends:
 >>>>
HELO rauno
MAIL FROM: <ra...@rauno.com>
RCPT TO: <ra...@rauno.com>
DATA
Subject: Test

Some dummy data, do not  send <CRLF>.<CRLF> yet
<<<<
Client 2 sends
 >>>>
HELO rauno
MAIL FROM: <ra...@rauno.com>
RCPT TO: <ra...@rauno.com>
DATA
Subject: Test

Some dummy data
<CRLF>.<CRLF>
<<<<

Client 2 doesn't get "250 Message received" until client 1 sends the 
final <CRLF>.<CRLF>

The problem is that sendMail is synchronized in James.java:
public synchronized void sendMail(MailAddress sender, Collection 
recipients, InputStream msg)

The workaround is to read the entire message before sendMail(

In SMTPHandler.java, private boolean parseCommand(String command) in 
DATA, before the call:
mailServer.sendMail(mail);
add:
mail.getSize(); // force the entire message to be read.

this forces MailImpl to read the entire mail before the call to sendMail(

I just got the latest CVS sources and SMTPHandler.java, doDATA(..) has a 
test on if maxmessagesize is set that will force the message to be read 
before sendMail(..)
If you don't limit the size of incoming mail just set this value very high.

-rauno


---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Re: James and multiple incoming mail.

Posted by Serge Knystautas <se...@lokitech.com>.
Thanks Rauno!  I noticed the hanging from time to time but was never able to
reliably recreate or identify the problem.  I'll look to have the message
loaded completely before calling sendMail, and will also look into why
sendMail is synchronized and seeing whether this can be relaxed at all.

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/
----- Original Message -----
From: "Rauno Palosaari" <ra...@rauno.com>
To: <ja...@jakarta.apache.org>
Sent: Tuesday, October 23, 2001 4:34 AM
Subject: James and multiple incoming mail.


> Hi guys and dolls.
>
> There is a problem with multiple incoming SMTP messages to James (and a
> workaround).
> The problem is that a thread receiving the DATA part from a client will
> block other clients DATA or QUITs.
>
> To reproduce it:
> Start 2 telnet sessions to James (telnet 127.0.0.1 25)
> Client 1 sends:
>  >>>>
> HELO rauno
> MAIL FROM: <ra...@rauno.com>
> RCPT TO: <ra...@rauno.com>
> DATA
> Subject: Test
>
> Some dummy data, do not  send <CRLF>.<CRLF> yet
> <<<<
> Client 2 sends
>  >>>>
> HELO rauno
> MAIL FROM: <ra...@rauno.com>
> RCPT TO: <ra...@rauno.com>
> DATA
> Subject: Test
>
> Some dummy data
> <CRLF>.<CRLF>
> <<<<
>
> Client 2 doesn't get "250 Message received" until client 1 sends the
> final <CRLF>.<CRLF>
>
> The problem is that sendMail is synchronized in James.java:
> public synchronized void sendMail(MailAddress sender, Collection
> recipients, InputStream msg)
>
> The workaround is to read the entire message before sendMail(
>
> In SMTPHandler.java, private boolean parseCommand(String command) in
> DATA, before the call:
> mailServer.sendMail(mail);
> add:
> mail.getSize(); // force the entire message to be read.
>
> this forces MailImpl to read the entire mail before the call to sendMail(
>
> I just got the latest CVS sources and SMTPHandler.java, doDATA(..) has a
> test on if maxmessagesize is set that will force the message to be read
> before sendMail(..)
> If you don't limit the size of incoming mail just set this value very
high.
>
> -rauno



---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


RE: James and multiple incoming mail.

Posted by Danny Angus <da...@thought.co.uk>.
Serge wrote:
>I also added code during the initialization() method to remove
> stranded files (when one of the pair of files is missing).

Nice touch.

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Re: James and multiple incoming mail.

Posted by Serge Knystautas <se...@lokitech.com>.
Rauno,

Thanks again for the reports.  There were actually multiple levels of
synchronization I had to undo.  First, the sendMail() method was
synchronized (actually several times) and then the repositories were
synchronized on the store() method.  This meant that even though threads
were obtaining locks, an insert or update would lock the entire repository.

I undid so much blocking, I started hitting big problems because the file
repository was assuming that delete() calls were completed after called.  I
had to switch to an in-memory list of keys in a repository, and it works
nicely.  I also added code during the initialization() method to remove
stranded files (when one of the pair of files is missing).

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/
----- Original Message -----
From: "Rauno Palosaari" <ra...@rauno.com>
To: <ja...@jakarta.apache.org>
Sent: Tuesday, October 23, 2001 4:34 AM
Subject: James and multiple incoming mail.


> Hi guys and dolls.
>
> There is a problem with multiple incoming SMTP messages to James (and a
> workaround).
> The problem is that a thread receiving the DATA part from a client will
> block other clients DATA or QUITs.
>
> To reproduce it:
> Start 2 telnet sessions to James (telnet 127.0.0.1 25)
> Client 1 sends:
>  >>>>
> HELO rauno
> MAIL FROM: <ra...@rauno.com>
> RCPT TO: <ra...@rauno.com>
> DATA
> Subject: Test
>
> Some dummy data, do not  send <CRLF>.<CRLF> yet
> <<<<
> Client 2 sends
>  >>>>
> HELO rauno
> MAIL FROM: <ra...@rauno.com>
> RCPT TO: <ra...@rauno.com>
> DATA
> Subject: Test
>
> Some dummy data
> <CRLF>.<CRLF>
> <<<<
>
> Client 2 doesn't get "250 Message received" until client 1 sends the
> final <CRLF>.<CRLF>
>
> The problem is that sendMail is synchronized in James.java:
> public synchronized void sendMail(MailAddress sender, Collection
> recipients, InputStream msg)
>
> The workaround is to read the entire message before sendMail(
>
> In SMTPHandler.java, private boolean parseCommand(String command) in
> DATA, before the call:
> mailServer.sendMail(mail);
> add:
> mail.getSize(); // force the entire message to be read.
>
> this forces MailImpl to read the entire mail before the call to sendMail(
>
> I just got the latest CVS sources and SMTPHandler.java, doDATA(..) has a
> test on if maxmessagesize is set that will force the message to be read
> before sendMail(..)
> If you don't limit the size of incoming mail just set this value very
high.
>
> -rauno



---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org