How to modfiy headers in and headers out
Yingyuan Cheng
yingyuan at staff.sina.com.cn
Thu Nov 1 06:22:22 MSK 2007
Hello Igor.
I tracked executing path using gdb, found the content of param "r"
(ngx_http_request_t) past by hook routine was a awful mess, and
r.headers_out.headers.last pointed to 0x22, which was in a protected
memory region. When executing path left my module and went to other
modules, the same param "r" was in its normal status. After I changed
the module code layout, such as moving "#include <openssl/md5>" after
nginx including headers, the problem diminished. Is it a compiling
problem? The configuring line is:
CFLAGS="-g" ./configure --with-debug
--add-module=/home/yingyuan/workspace/ngx_http_sessid_filter/
ngx_http_sessid_filter_module "borrows" code snippets from
ngx_http_userid_filter_module and ngx_http_upstream_ip_hash_module.
First it acts as a load balancer, dispatching requests to backends based
on cookie. If the cookie not found in request, it'll generate a new one.
Then in the filter phase, it sends the cookie to client if it was
generated newly in balancing phase. So we can make the client always
dispatched to the same backend.
Another question I want to ask: May I change request headers_out in
upstream_init_peer phase?
Thank you very much.
Best Regards
--
yingyuan
Igor Sysoev 写道:
> On Wed, Oct 31, 2007 at 07:45:39PM +0800, Yingyuan Cheng wrote:
>
>
>> After changed the order of my filter module defined in
>> objs/ngx_modules.c which should go after ngx_http_header_filter module,
>> it works. But I still get a segment fault when calling
>> ngx_list_push(&r->headers_out.headers) in filter hook function.
>>
>> Anyone could give me a explanation?
>>
>> Thanks very much.
>>
>
> ngx_list_push(&r->headers_out.headers) should not cause segfault in this phase.
> Could you show more code ?
>
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: config
URL: <http://nginx.org/pipermail/nginx/attachments/20071101/8efd2ad6/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ngx_http_sessid_filter_module.c
Type: text/x-csrc
Size: 18601 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20071101/8efd2ad6/attachment.c>
More information about the nginx
mailing list