<br>The documentation for the mail proxy module state the "so_keepalive" variable can be used to toggle keepalive functionality to the backend server.<br><br>The actual code though uses this configuration variable to drive keepalive functionality on the client side connection though. Below is a short patch which changes the keepalive functionality to the backend server.<br>
<br>--- ngx_mail_proxy_module.c.orig 2009-11-02 10:14:17.000000000 -0500<br>+++ ngx_mail_proxy_module.c 2010-03-01 14:09:20.866649958 -0500<br>@@ -120,18 +120,6 @@<br> <br> cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);<br>
<br>- if (cscf->so_keepalive) {<br>- keepalive = 1;<br>-<br>- if (setsockopt(s->connection->fd, SOL_SOCKET, SO_KEEPALIVE,<br>- (const void *) &keepalive, sizeof(int))<br>
- == -1)<br>- {<br>- ngx_log_error(NGX_LOG_ALERT, s->connection->log, ngx_socket_errno,<br>- "setsockopt(SO_KEEPALIVE) failed");<br>- }<br>- }<br>
-<br> p = ngx_pcalloc(s->connection->pool, sizeof(ngx_mail_proxy_ctx_t));<br> if (p == NULL) {<br> ngx_mail_session_internal_server_error(s);<br>@@ -154,6 +142,18 @@<br> return;<br> }<br>
<br>+ if (cscf->so_keepalive) {<br>+ keepalive = 1;<br>+<br>+ if (setsockopt(s->proxy->upstream.connection->fd, SOL_SOCKET, SO_KEEPALIVE,<br>+ (const void *) &keepalive, sizeof(int))<br>
+ == -1)<br>+ {<br>+ ngx_log_error(NGX_LOG_ALERT, s->connection->log, ngx_socket_errno,<br>+ "setsockopt(SO_KEEPALIVE) failed");<br>+ }<br>+ }<br>
+<br> ngx_add_timer(p->upstream.connection->read, cscf->timeout);<br> <br> p->upstream.connection->data = s;<br><br clear="all"><br>-- <br>Sridhar<br>