[DEV] nginx ngx_hash_t usage, and other questions...

Brice Figureau brice+nginx at daysofwonder.com
Mon Sep 24 22:14:19 MSD 2007


Hi,

I'm in the progress of hacking an upload progress module for nginx, where
I will track some request and answer from other requests what was
uploaded.

I need to store an upload request in a hash table whose key is a
connection id sent in an upload header.

My idea was to use the the ngx_hash_t type to do that, but looking at the
source code I'm puzzled and have the following questions:

1) Is it possible to init the hash with nelts=0 and names=NULL ?
I don't know the elements at the hash creation time.

2) What is the purpose of the ngx_hash_keys_arrays_t parameter in
ngx_hash_add_key ?
After initing one, what should I put in there ?

I also have a few more general or basic questions:

1) There are a lot of ngx_str_t used, but all the ngx_string.c functions
are using u_char* . Does it mean the strings are always null terminated
and the ngx_str_t len parameter is used for something else ?
So to use ngx_strcmp with 2 ngx_str_t, I just have to call it with the value?

2) Can I register an handler or a phase handler that will be triggered at
the end of a request (and if yes how) ?
This is to do the cleanup in my hash table containing the uploading requests.

Many thanks for the answer,
-- 
Brice Figureau







More information about the nginx mailing list