Welcome! Log In Create A New Profile

Advanced

Re: pls. help for adding another parameter to ngx_upstream_server

moto kawasaki
November 26, 2013 11:39AM
Hello,

I am the questioner about setfib feature on the upstream side.
And I am back for asking you comments/suggestions/help.
Thank you very much in advance.

Please refer the following URL for the conversation before.
http://forum.nginx.org/read.php?29,244686

mdounin> Well, as far as I can tell there is no reasons to do per-server
mdounin> setfib in this usecase, and
mdounin>
mdounin> proxy_setfib N;
mdounin>
mdounin> should be enough. It should be much easier to implement than what
mdounin> you are trying to do in your patch.

Thank you very much, Mr. Dounin, I followed your advice.

Now, I am refering src/http/modules/ngx_http_upstream_keepalive_module.c,
and create a new module "ngx_http_upstream_proxy_setfib_module.c".

With this module, I can write "setfib N" in nginx.conf like;

http {
(snip)
upstream UPSTREAM {
proxy_setfib 5;
server 10.200.195.70:80 max_fails=3 fail_timeout=300;
}
}

And also I can create server config for this module, and the config
"proxy_setfib 5" can be read and set into server config.

Now, I want to do setsockopt(2) with SO_SETFIB, so that I can make a
connection to upstream (contents) server with a given fib number (5 in
above case).

But I am lost in the nginx architecture, so please advice me in which
function should I call setsockopt() ??

My incomplete understandings are:

- I need to override ngx_event_connect_peer(), since this function
has socket(), setsockopt(SO_RCVBUF), and bind().
I cannot find any hook/callback point between socket() and bind().

http://lxr.evanmiller.org/http/source/event/ngx_event_connect.c#L15

- ngx_event_connect_peer() is called from ngx_http_upstream_connect()
etc. but I don't understand when and by which function it is
called.

- seeing keepalive module, the initialization chain is connected:

ngx_http_upstream_keepalive()
-> ngx_http_upstream_init_keepalive()
-> ngx_http_upstream_init_keepalive_peer()
-> ngx_http_upstream_init_get_keepalive_peer()
-> ...

http://lxr.evanmiller.org/http/source/http/ngx_http_upstream.c#L1132

But I could not find any place on that chain which might call
ngx_http_upstream_connect() so far.


I am embarrassed to ask such basic questions but any
comments/suggestions are really appreciated.

I've attached my module source code, configure option, and nginx.conf.
I am running them on FreeBSD 9.2-RELEASE (amd64), and nginx version is
1.4.3.

Thank you very much.





Best Regards,


--
moto kawasaki <moto@kawasaki3.org>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

pls. help for adding another parameter to ngx_upstream_server

moto kawasaki 1237 November 15, 2013 03:38AM

Re: pls. help for adding another parameter to ngx_upstream_server

Vladimir Homutov 444 November 15, 2013 04:44AM

Re: pls. help for adding another parameter to ngx_upstream_server

moto kawasaki 498 November 16, 2013 04:34AM

Re: pls. help for adding another parameter to ngx_upstream_server

Maxim Dounin 490 November 18, 2013 09:10AM

Re: pls. help for adding another parameter to ngx_upstream_server Attachments

moto kawasaki 442 November 26, 2013 11:39AM

Re: pls. help for adding another parameter to ngx_upstream_server

Maxim Dounin 430 November 26, 2013 11:39AM

Re: pls. help for adding another parameter to ngx_upstream_server

moto kawasaki 379 November 26, 2013 09:08PM

Re: pls. help for adding another parameter to ngx_upstream_server

moto kawasaki 545 November 29, 2013 02:06AM

Re: pls. help for adding another parameter to ngx_upstream_server

Maxim Dounin 451 November 15, 2013 05:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 234
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready