From: Vlad S. <vl...@cr...> - 2008-11-07 21:26:28
|
This is the simple PHP page that triggers hanging, when attached to the nsd, backtrace on all thread show they all are in the condwait or poll wait, seems like sent/expected bytes miscalculation. <?php $test = @$_COOKIE["test"]; setcookie("test", "1", time() + 60, '/'); if ($test == "1") { header("HTTP/1.0 304 Not Modified"); exit(); } ?> test page |
From: Stephen D. <sd...@gm...> - 2008-11-07 22:18:29
|
On Fri, Nov 7, 2008 at 9:23 PM, Vlad Seryakov <vl...@cr...> wrote: > > This is the simple PHP page that triggers hanging, when attached to the > nsd, backtrace on all thread show they all are in the condwait or poll > wait, seems like sent/expected bytes miscalculation. > > <?php > > $test = @$_COOKIE["test"]; > setcookie("test", "1", time() + 60, '/'); > > if ($test == "1") { > header("HTTP/1.0 304 Not Modified"); > exit(); > } > ?> > test page > Make a 'tests' directory and add the above snippet. Make it run from 'make test'. The 'nsvfs' module in CVS is an example of an external module which has tests using the nstest_http command. You could just 'cp -a ../nsvfs/tests tests' and then cut 'n paste from the Makefile. |
From: Vlad S. <vl...@cr...> - 2008-11-07 22:27:49
|
It is funny, using telnet and submitting same headers never triggers this, but when using firefox, after sevrral requests it hangs, and after timeout outputs: 0 c test page 0 as it lost sequence and puts the whole buffer with trailer as the first one. I want to find the problem and then will put test for future checks Stephen Deasey wrote: > On Fri, Nov 7, 2008 at 9:23 PM, Vlad Seryakov <vl...@cr...> wrote: >> This is the simple PHP page that triggers hanging, when attached to the >> nsd, backtrace on all thread show they all are in the condwait or poll >> wait, seems like sent/expected bytes miscalculation. >> >> <?php >> >> $test = @$_COOKIE["test"]; >> setcookie("test", "1", time() + 60, '/'); >> >> if ($test == "1") { >> header("HTTP/1.0 304 Not Modified"); >> exit(); >> } >> ?> >> test page >> > > > Make a 'tests' directory and add the above snippet. Make it run from > 'make test'. > > The 'nsvfs' module in CVS is an example of an external module which > has tests using the nstest_http command. You could just 'cp -a > ../nsvfs/tests tests' and then cut 'n paste from the Makefile. > |
From: Stephen D. <sd...@gm...> - 2008-11-07 22:43:32
|
On Fri, Nov 7, 2008 at 10:24 PM, Vlad Seryakov <vl...@cr...> wrote: > I want to find the problem and then will put test for future checks No, you write the test to help find the bug. > It is funny, using telnet and submitting same headers never triggers > this, but when using firefox, after sevrral requests it hangs Rather than typing the same thing into telnet over and over again, and then repeating it with firefox, and then hoping other people can guess right and reproduce what you're doing and have them repeat it all too, why not check into CVS a 10 line test file? It's just GOT to be easier, right? |
From: Vlad S. <vl...@cr...> - 2008-11-08 03:39:03
|
Added, runs fine but that the thing, it hangs in firefox, not in the test Stephen Deasey wrote: > On Fri, Nov 7, 2008 at 10:24 PM, Vlad Seryakov <vl...@cr...> wrote: > >> I want to find the problem and then will put test for future checks > > > No, you write the test to help find the bug. > > >> It is funny, using telnet and submitting same headers never triggers >> this, but when using firefox, after sevrral requests it hangs > > > Rather than typing the same thing into telnet over and over again, and > then repeating it with firefox, and then hoping other people can guess > right and reproduce what you're doing and have them repeat it all too, > why not check into CVS a 10 line test file? It's just GOT to be > easier, right? > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Stephen D. <sd...@gm...> - 2008-11-08 04:17:44
|
On Sat, Nov 8, 2008 at 3:38 AM, Vlad Seryakov <vl...@cr...> wrote: > > Added, runs fine but that the thing, it hangs in firefox, not in the test > OK, so there's a difference. Maybe keepalive -- you mentioned what looked like responses garbled together? An HTTP 1.1 request will force keepalive: test php-1.1 {sequential requests w/keepalive} -body { foreach n {0 1 2} { lappend results [nstest_http -http 1.1 \ -getbody 1 \ -getheaders content-length \ GET /test.php] } set results } -cleanup { unset -nocomplain results } -result "{200 10 {test page\n}} {200 10 {test page\n}} {200 10 {test page\n}}" Also, can you adjust the build to use an already installed php? See: README.SELF-CONTAINED-EXTENSIONS in the php source for directions. |
From: Vlad S. <vl...@cr...> - 2008-11-08 05:00:28
|
Yes, keep-alive is the key, nshttp_test closes connection so it cannot test this I tried that but could not get it to work, it generates configure but when i run it i never could make it finish, there are always some errors. Stephen Deasey wrote: > On Sat, Nov 8, 2008 at 3:38 AM, Vlad Seryakov <vl...@cr...> wrote: >> Added, runs fine but that the thing, it hangs in firefox, not in the test >> > > > OK, so there's a difference. > > Maybe keepalive -- you mentioned what looked like responses garbled > together? An HTTP 1.1 request will force keepalive: > > test php-1.1 {sequential requests w/keepalive} -body { > foreach n {0 1 2} { > lappend results [nstest_http -http 1.1 \ > -getbody 1 \ > -getheaders content-length \ > GET /test.php] > } > set results > } -cleanup { > unset -nocomplain results > } -result "{200 10 {test page\n}} {200 10 {test page\n}} {200 10 {test page\n}}" > > > > Also, can you adjust the build to use an already installed php? See: > README.SELF-CONTAINED-EXTENSIONS in the php source for directions. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Stephen D. <sd...@gm...> - 2008-11-08 18:29:18
|
On Sat, Nov 8, 2008 at 5:00 AM, Vlad Seryakov <vl...@cr...> wrote: > Yes, keep-alive is the key, nshttp_test closes connection so it cannot > test this /* * php_ns_sapi_send_headers() flushes the headers to the client. * Called before real content is sent by PHP. */ static int php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { ns_context *ctx = SG(server_context); if (ctx->conn != NULL) { Ns_ConnSetResponseStatus(ctx->conn, SG(sapi_headers).http_response_code); } Ns_ConnWriteData(ctx->conn, NULL, 0, NS_CONN_STREAM); return SAPI_HEADER_SENT_SUCCESSFULLY; } Does this actually need to flush? It depends when php calls it. In the case where there's no body, eg. a 302 redirect, then maybe this signals 'all done' and you're to write the headers. In the case where there is a body it's not needed because naviserver will construct and dump the headers when you try to write the first data, and it will send both with a single syscall (and packet, if it fits), which is more efficient. So you should try not to flush. You might try to do nothing in this call, and detect when you've finished sending in the case of a zero-length body some other way. When php returns control to your Ns_Op function you could check to see if any bytes were sent and if not, flush the headers. But anyway, you're checking for ctx->conn != NULL before setting the response code, then using it unconditionally when you write the data. Ns_ConnWriteData can fail but you're ignoring the return code and returning success. /* * php_ns_sapi_header_handler() sets a HTTP reply header to be sent to the client. */ Does php try to set a length header? You may need to check for it in here and call Ns_ConnSetLengthHeader. /* * php_ns_sapi_ub_write() writes data to the client connection. */ static int php_ns_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { ns_context *ctx = SG(server_context); if (!ctx->conn) { int size = ctx->buffer ? strlen(ctx->buffer) : 0; ctx->buffer = ns_realloc(ctx->buffer, size + str_length + 1); strncpy(&(ctx->buffer[size]), str, str_length); ctx->buffer[size + str_length] = 0; return str_length; } if (Ns_ConnWriteData(ctx->conn, (void *) str, str_length, NS_CONN_STREAM) != NS_OK) { php_handle_aborted_connection(); } return str_length; } Whether the write succeeds or fails, you're returning the original buffer length, which I guess signals success to php. It might be hard to figure out exactly how much did get sent, because conn->nContentSent includes the headers bytes. But maybe php doesn't care? You'll have to check if you can return -1 or 0 or something. You might also want to check if php exposes it's buffering. If you can figure out that your ub_write call is being called with all the data that's going to be sent (the script has finished executing) or the last piece of data, you shouldn't pass the flag NS_CONN_STREAM. Otherwise, you should. > I tried that but could not get it to work, it generates configure but > when i run it i never could make it finish, there are always some errors. Do you need to buy into the full build process? Maybe you can just pull in the header and link against the library..? |
From: Vlad S. <vl...@cr...> - 2008-11-08 20:47:36
|
> > Does this actually need to flush? > > It depends when php calls it. In the case where there's no body, eg. a > 302 redirect, then maybe this signals 'all done' and you're to write > the headers. In the case where there is a body it's not needed because > naviserver will construct and dump the headers when you try to write > the first data, and it will send both with a single syscall (and > packet, if it fits), which is more efficient. > > So you should try not to flush. You might try to do nothing in this > call, and detect when you've finished sending in the case of a > zero-length body some other way. When php returns control to your > Ns_Op function you could check to see if any bytes were sent and if > not, flush the headers. I tried it, with code before senfile implementation where we had flush function it worked perfectly, so PHP is calling this only when it needs to actually send headers. Not sure i can find out about body coming, even in 302 case there can be body but may be not. Will try again > But anyway, you're checking for ctx->conn != NULL before setting the > response code, then using it unconditionally when you write the data. > > Ns_ConnWriteData can fail but you're ignoring the return code and > returning success It is mostly possible that the problem is in nsphp :-(( > > > Does php try to set a length header? You may need to check for it in > here and call Ns_ConnSetLengthHeader. > This i checked, no length > > Whether the write succeeds or fails, you're returning the original > buffer length, which I guess signals success to php. It might be hard > to figure out exactly how much did get sent, because > conn->nContentSent includes the headers bytes. But maybe php doesn't > care? You'll have to check if you can return -1 or 0 or something. when abort is called, i do not return str_length, it might be logjmp inside php > You might also want to check if php exposes it's buffering. If you can > figure out that your ub_write call is being called with all the data > that's going to be sent (the script has finished executing) or the > last piece of data, you shouldn't pass the flag NS_CONN_STREAM. > Otherwise, you should. No buffering, PHP calls it with all pieces separately > > >> I tried that but could not get it to work, it generates configure but >> when i run it i never could make it finish, there are always some errors. > > > > Do you need to buy into the full build process? Maybe you can just > pull in the header and link against the library..? The problem with PHP that it can support only one SAPI implementation and nsphp is not just extesion but SAPI handler, so just compiling it as extension will not work |
From: Vlad S. <vl...@cr...> - 2008-11-08 22:19:13
|
The major difference between previous version and current that in the previous version we always closed connection, even in 1.1, PHP streaming was not using chunked encoding explicitly and the server never auto-assigned it. In current version the server decided and because we always keep-alive and in chunked, Firefox after 3 request hangs because reply is not correct. This is strange because in telnet session it looks fine but my eye may not be protocol-demanding like Firefox. Vlad Seryakov wrote: >> Does this actually need to flush? >> >> It depends when php calls it. In the case where there's no body, eg. a >> 302 redirect, then maybe this signals 'all done' and you're to write >> the headers. In the case where there is a body it's not needed because >> naviserver will construct and dump the headers when you try to write >> the first data, and it will send both with a single syscall (and >> packet, if it fits), which is more efficient. >> >> So you should try not to flush. You might try to do nothing in this >> call, and detect when you've finished sending in the case of a >> zero-length body some other way. When php returns control to your >> Ns_Op function you could check to see if any bytes were sent and if >> not, flush the headers. > > I tried it, with code before senfile implementation where we had flush > function it worked perfectly, so PHP is calling this only when it needs > to actually send headers. Not sure i can find out about body coming, > even in 302 case there can be body but may be not. Will try again > >> But anyway, you're checking for ctx->conn != NULL before setting the >> response code, then using it unconditionally when you write the data. >> >> Ns_ConnWriteData can fail but you're ignoring the return code and >> returning success > > It is mostly possible that the problem is in nsphp :-(( > >> >> Does php try to set a length header? You may need to check for it in >> here and call Ns_ConnSetLengthHeader. >> > > This i checked, no length > > >> Whether the write succeeds or fails, you're returning the original >> buffer length, which I guess signals success to php. It might be hard >> to figure out exactly how much did get sent, because >> conn->nContentSent includes the headers bytes. But maybe php doesn't >> care? You'll have to check if you can return -1 or 0 or something. > > when abort is called, i do not return str_length, it might be logjmp > inside php > > >> You might also want to check if php exposes it's buffering. If you can >> figure out that your ub_write call is being called with all the data >> that's going to be sent (the script has finished executing) or the >> last piece of data, you shouldn't pass the flag NS_CONN_STREAM. >> Otherwise, you should. > > No buffering, PHP calls it with all pieces separately > >> >>> I tried that but could not get it to work, it generates configure but >>> when i run it i never could make it finish, there are always some errors. >> >> >> Do you need to buy into the full build process? Maybe you can just >> pull in the header and link against the library..? > > The problem with PHP that it can support only one SAPI implementation > and nsphp is not just extesion but SAPI handler, so just compiling it as > extension will not work > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Stephen D. <sd...@gm...> - 2008-11-08 23:59:57
|
On Sat, Nov 8, 2008 at 8:47 PM, Vlad Seryakov <vl...@cr...> wrote: >> >> Do you need to buy into the full build process? Maybe you can just >> pull in the header and link against the library..? > > The problem with PHP that it can support only one SAPI implementation > and nsphp is not just extesion but SAPI handler, so just compiling it as > extension will not work > There's an --enable-embed=shared option, and it seems to work (added). |
From: Vlad S. <vl...@cr...> - 2008-11-09 03:33:14
|
What distribution do you use? In my Archlinux this does not work, they provide Apache module only, so i need to recompile PHP anyway. In such cases README and automated way to rebuild it would be nice, it is gone from Makefile now Stephen Deasey wrote: > On Sat, Nov 8, 2008 at 8:47 PM, Vlad Seryakov <vl...@cr...> wrote: >>> Do you need to buy into the full build process? Maybe you can just >>> pull in the header and link against the library..? >> The problem with PHP that it can support only one SAPI implementation >> and nsphp is not just extesion but SAPI handler, so just compiling it as >> extension will not work >> > > > There's an --enable-embed=shared option, and it seems to work (added). > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Vlad S. <vl...@cr...> - 2008-11-08 05:11:45
|
In telnet session, i do it endlessly, no hangs, mistery GET /test.php HTTP/1.1 Host: vlad.mpower.net Cookie: test=1 HTTP/1.1 304 Not Modified MIME-Version: 1.0 Server: NaviServer/4.99.3 Date: Sat, 08 Nov 2008 05:06:44 GMT X-Powered-By: PHP/5.2.6 Set-Cookie: test=1; expires=Sat, 08-Nov-2008 05:07:44 GMT; path=/ Content-type: text/html Connection: keep-alive Transfer-Encoding: chunked 0 Stephen Deasey wrote: > On Sat, Nov 8, 2008 at 3:38 AM, Vlad Seryakov <vl...@cr...> wrote: >> Added, runs fine but that the thing, it hangs in firefox, not in the test >> > > > OK, so there's a difference. > > Maybe keepalive -- you mentioned what looked like responses garbled > together? An HTTP 1.1 request will force keepalive: > > test php-1.1 {sequential requests w/keepalive} -body { > foreach n {0 1 2} { > lappend results [nstest_http -http 1.1 \ > -getbody 1 \ > -getheaders content-length \ > GET /test.php] > } > set results > } -cleanup { > unset -nocomplain results > } -result "{200 10 {test page\n}} {200 10 {test page\n}} {200 10 {test page\n}}" > > > > Also, can you adjust the build to use an already installed php? See: > README.SELF-CONTAINED-EXTENSIONS in the php source for directions. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |