nginx does not close the connection to backend pop3 server

Igor Sysoev is at rambler-co.ru
Tue Jul 24 12:08:56 MSD 2007


On Tue, Jul 24, 2007 at 02:33:23PM +0800, Joe Wong wrote:

> Ok, the log has been sent to you directly in another mail.

Try the attached patch.

> - Joe
> 
> Igor Sysoev wrote:
> >On Tue, Jul 24, 2007 at 10:16:03AM +0800, Joe Wong wrote:
> >
> >  
> >>I am evaluating nginx pop3 proxy function and encounter 1 problem. Here 
> >>is my setup:
> >>
> >>OS: RedHat FC7 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT 2007 
> >>i686 i686 i386 GNU/Linux
> >>GCC: gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)
> >>Nginx version: 0.5.26
> >>Config option: --with-debug --with-mail --with-select_module
> >>
> >>Nginx config:
> >>daemon on;
> >>user root;
> >>worker_processes 10;
> >>
> >>error_log logs/error.log debug;
> >>pid       logs/nginx.pid;
> >>
> >>#maximum total connections of each worker
> >>events {
> >>   worker_connections 100;
> >>#    use select;
> >>   debug_connection 127.0.0.1;
> >>}
> >>
> >>mail {
> >>   auth_http   localhost:8088/auth.php;
> >>
> >>   pop3_capabilities  "TOP"  "USER";
> >>   pop3_auth          plain;
> >>   imap_capabilities  "IMAP4rev1"  "UIDPLUS";
> >>
> >>   #pop3 configuration
> >>   server {
> >>       listen     110;
> >>       protocol   pop3;
> >>       proxy      on;
> >>   }
> >>}
> >>
> >>
> >>Test case:
> >>- A mailbox with message around 10M large
> >>- Use telnet to port 110, issue the USER/PASS command to login
> >>- Issue RETR 1 to download the 10M message
> >>- Close the connection by pressing Ctrl-] then 'q' right after RETR 
> >>command is issued
> >>
> >>At this time,  Netstat shows that the connection from nginx to the 
> >>backend POP3 server remains connected.
> >>
> >>Now, I repeat the above test case with "use select" turns on in 
> >>nginx.conf.  This time, I don't see the connection to backend pop3 
> >>remains after my client connection to nginx is terminated in the middle. 
> >>I suspect this is something to do with epoll call?
> >>
> >>I only did the test on POP3 proxy, not sure if it has the same behaviour 
> >>on HTTP.
> >>
> >>Please let me know if you need more information.
> >>    
> >
> >Could you create debug logs for epoll and select cases, and send them to 
> >me ?
> >
> >
> >  
> 

-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/mail/ngx_mail_proxy_module.c
===================================================================
--- src/mail/ngx_mail_proxy_module.c	(revision 660)
+++ src/mail/ngx_mail_proxy_module.c	(working copy)
@@ -866,9 +866,11 @@
 
     c->log->action = "proxying";
 
-    if ((s->connection->read->eof || s->proxy->upstream.connection->read->eof)
-        && s->buffer->pos == s->buffer->last
-        && s->proxy->buffer->pos == s->proxy->buffer->last)
+    if ((s->connection->read->eof && s->buffer->pos == s->buffer->last)
+        || (s->proxy->upstream.connection->read->eof
+            && s->proxy->buffer->pos == s->proxy->buffer->last)
+        || (s->connection->read->eof
+            && s->proxy->upstream.connection->read->eof))
     {
         action = c->log->action;
         c->log->action = NULL;


More information about the nginx mailing list