# Documentation doesn't match code

**URL:** <https://www.ruby-forum.com/t/documentation-doesnt-match-code/184384>\
**Category:** NGINX\
**Created:** [March 1, 2010, 8:19pm UTC](https://www.ruby-forum.com/t/documentation-doesnt-match-code/184384 "2010-03-01T20:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sridhar\_basam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@sridhar\_basam](https://www.ruby-forum.com/u/sridhar_basam)\
**Post date:** [March 1, 2010, 8:19pm UTC](https://www.ruby-forum.com/t/documentation-doesnt-match-code/184384/1 "2010-03-01T20:19:43Z")

</div>

The documentation for the mail proxy module state the “so\_keepalive”  
variable can be used to toggle keepalive functionality to the backend  
server.

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.

— ngx\_mail\_proxy\_module.c.orig 2009-11-02 10:14:17.000000000  
-0500  
+++ ngx\_mail\_proxy\_module.c 2010-03-01 14:09:20.866649958 -0500  
@@ -120,18 +120,6 @@

```
 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);

```

- if (cscf-\>so\_keepalive) {
- 

```
   keepalive = 1;

```

- 
- 

```
   if (setsockopt(s->connection->fd, SOL_SOCKET, SO_KEEPALIVE,

```

- 

```
                  (const void *) &keepalive, sizeof(int))

```

- 

```
           == -1)

```

- 

```
   {

```

- 

```
       ngx_log_error(NGX_LOG_ALERT, s->connection->log,

```

ngx\_socket\_errno,

- 

```
                     "setsockopt(SO_KEEPALIVE) failed");

```

- 

```
   }

```

- }
- p = ngx\_pcalloc(s-\>connection-\>pool, sizeof(ngx\_mail\_proxy\_ctx\_t));  
if (p == NULL) {  
ngx\_mail\_session\_internal\_server\_error(s);  
@@ -154,6 +142,18 @@  
return;  
}

- if (cscf-\>so\_keepalive) {
- 

```
   keepalive = 1;

```

- 
- 

```
   if (setsockopt(s->proxy->upstream.connection->fd, SOL_SOCKET,

```

SO\_KEEPALIVE,

- 

```
                  (const void *) &keepalive, sizeof(int))

```

- 

```
           == -1)

```

- 

```
   {

```

- 

```
       ngx_log_error(NGX_LOG_ALERT, s->connection->log,

```

ngx\_socket\_errno,

- 

```
                     "setsockopt(SO_KEEPALIVE) failed");

```

- 

```
   }

```

- }

- ngx\_add\_timer(p-\>upstream.connection-\>read, cscf-\>timeout);

---

<div class="post-metadata">

**Author:** ![sridhar\_basam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@sridhar\_basam](https://www.ruby-forum.com/u/sridhar_basam)\
**Post date:** [March 1, 2010, 8:43pm UTC](https://www.ruby-forum.com/t/documentation-doesnt-match-code/184384/2 "2010-03-01T20:43:44Z")

</div>

Hello!

On Mon, Mar 01, 2010 at 02:18:58PM -0500, sridhar basam wrote:

> The documentation for the mail proxy module state the “so\_keepalive”  
> variable can be used to toggle keepalive functionality to the backend  
> server.

Wow. Where did you find one? May be you mean wiki?

> 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.

It is believed that it works as expected - sets SO\_KEEPALIVE on  
client socket once we are about to open backend connection (which  
is usually resource consuming, as backends are used to follow  
process per connection model). This allows to free backend  
connections early as long as clients silently disappear.

You may want to fix wiki instead (it seems to be down right now  
though).

Maxim D.

---

<div class="post-metadata">

**Author:** ![sridhar\_basam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@sridhar\_basam](https://www.ruby-forum.com/u/sridhar_basam)\
**Post date:** [March 1, 2010, 9:24pm UTC](https://www.ruby-forum.com/t/documentation-doesnt-match-code/184384/3 "2010-03-01T21:24:43Z")

</div>

On Mon, Mar 1, 2010 at 2:43 PM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

That is right, it was on the english wiki. I have corrected it on the  
wiki,  
if you want to give it a look.

> connections early as long as clients silently disappear.
> 
> You may want to fix wiki instead (it seems to be down right now  
> though).

Yeah, guess doing it on either end is fine, since the backend is going  
to  
get torn down if the client is detected as down.

sridhar
