# Question on SG(server_context) in sapi_apache2.c

- Thread: https://externals.io/message/6196
- Original archive: https://news-web.php.net/php.internals/6196
- Started by Ananth Kesari on 2003-12-04T10:57:44+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6196 — Ananth Kesari — 2003-12-04T10:57:44+00:00

URL: https://externals.io/message/6196#6196

Hi,

As some of you may know, I am working of porting PHP onto NetWare.
I find this in sapi_apache2.c code:

In the "php_post_read_request" function, we register a cleanup
function called "php_server_context_cleanup" to clear clear out
the "SG(server_context)" after each request. We pass the pointer
of this variable to the cleanup function. The comment says that
this is done to cater to those cases where this is handled by
a different thread.

Now, in the "php_server_context_cleanup" function, we just
put this value to NULL.

Now my questions are:

1. Why should we explicitly make SG(server_context) to `NULL` 
at the end of every request? What is the purpose of this operation?
Doesn't this variable get assigned to `NULL` at the start of each
request?
In that case there is nothing to do in the
"php_server_context_cleanup"
function.

2. If the "php_server_context_cleanup" function is required,
then what is inside this function, isn't this equivalent to making
SG(server_context) = `NULL` in the "php_server_context_cleanup"
function? If this so, they why pass the pointer of this variable
- why not assign is directly to NULL. Then the
"php_server_context_cleanup"
function looks like this:

	TSRMLS_FETCH();
	SG(server_context) = NULL;

Can you throw some light on this?

Thanks,
Ananth.
