I'm using G-Wan v4.12.31.
Does anybody know why get_env(US_VHOST_DATA) returns NULL on first invocation of main() in handlers/main.c?
int init(int argc, char *argv[])
{
u32 *states = (u32 *)get_env(argv, US_HANDLER_STATES);
*states = (1 << HDL_AFTER_READ);
return 0;
}
int main(int argc, char *argv[])
{
void **vhost = (void **)get_env(argv, US_VHOST_DATA);
printf(%p\n", vhost); //NULL first time, non-NULL all other times
return 255;
}
The
get_env(US_VHOST_DATA)call returns the virtual host information.There is no
host informationavailable for G-WAN as long as theclient requesthas not beenparsed.This is why no meaningfull host can be returned before the HDL_AFTER_PARSE handler state and why G-WAN returns NULL.