Why get_env(US_VHOST_DATA) is NULL on first invocation of main() in handlers/main.c

65 views Asked by At

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;
}
1

There are 1 answers

1
Gil On

The get_env(US_VHOST_DATA) call returns the virtual host information.

There is no host information available for G-WAN as long as the client request has not been parsed.

This is why no meaningfull host can be returned before the HDL_AFTER_PARSE handler state and why G-WAN returns NULL.