On Saturday 07 May 2005 08:30, Stas Bekman wrote: > Torsten Foertsch wrote: > > Hi, > > > > yesterday I have patched my apache with this patch and now I have noticed > > that testing mod_perl hangs in t/protocol/pseudo_http. The reason is > > simple and to be expected. t/protocol/pseudo_http tests a protocol module > > that is greeting the client with "HELO" before receiving any data. Since > > the patch prevents accept(2) from returning before data has been received > > from the client the connection is not accepted. Hence no piece of code > > gets chance to send "HELO". > > > > Maybe it is worth to change the test so that the client must send > > someting at first? > > > > I could provide a patch. > > What's that patch you are talking about, Torsten?
Sorry for not providing a link. Here it is: http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=111523765005281&w=2 The whole thing came from a discussion about the Timeout configuration directive, see http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=111513459203781&w=2 One proposed solution was to enable BSD accept-filtering. Thus, accept(2) will return only if a complete HTTP-request is ready to be read. For Linux a similar mechanism exists with the TCP_DEFER_ACCEPT socket option. According to the thread Apache 2.1 uses this option. Then a backport was suggested resulting in the patch. > This workaround doesn't sound right. A protocol handler (server) must be > able to start the conversation first. If not, many protocols relying on > the server's greeing (e.g. SMTP) won't work. e.g., see: > http://www.samlogic.net/articles/smtp.htm I know that it would break some protocols. It can be accepted to httpd-2.0 only if it is configurable. I was asking whether testing mod_perl should rely on the server's ability to send data first. If not, the attached patch changes slightly the protocol initialization. Now the client should send "HELO". The server replies "Nice to meet you". Torsten
diff -Naur mod_perl-2.0.0-RC6/t/protocol/pseudo_http.t mod_perl-2.0.0-RC6.new/t/protocol/pseudo_http.t
--- mod_perl-2.0.0-RC6/t/protocol/pseudo_http.t 2004-11-27 19:09:21.000000000 +0100
+++ mod_perl-2.0.0-RC6.new/t/protocol/pseudo_http.t 2005-05-06 16:06:28.000000000 +0200
@@ -29,7 +29,9 @@
my $socket = Apache::TestRequest::vhost_socket($module);
ok $socket;
- expect_reply($socket, "HELO", "HELO", "greeting");
+ t_debug("send: HELO");
+ print $socket "HELO";
+ expect($socket, "Nice to meet you", "greeting");
expect_reply($socket, "Login:", $login, "login");
expect_reply($socket, "Password:", $passgood, "good password");
expect($socket, "Welcome to TestProtocol::pseudo_http", "banner");
@@ -44,7 +46,9 @@
my $socket = Apache::TestRequest::vhost_socket($module);
ok $socket;
- expect_reply($socket, "HELO", "HELO", "greeting");
+ t_debug("send: HELO");
+ print $socket "HELO";
+ expect($socket, "Nice to meet you", "greeting");
expect_reply($socket, "Login:", $login, "login");
t_client_log_error_is_expected();
expect_reply($socket, "Password:", $passbad, "wrong password");
diff -Naur mod_perl-2.0.0-RC6/t/protocol/TestProtocol/pseudo_http.pm mod_perl-2.0.0-RC6.new/t/protocol/TestProtocol/pseudo_http.pm
--- mod_perl-2.0.0-RC6/t/protocol/TestProtocol/pseudo_http.pm 2005-04-05 18:17:44.000000000 +0200
+++ mod_perl-2.0.0-RC6.new/t/protocol/TestProtocol/pseudo_http.pm 2005-05-06 16:00:52.000000000 +0200
@@ -65,10 +65,12 @@
my $c = shift;
my $socket = $c->client_socket;
- $socket->send("HELO\n");
my $reply = getline($socket) || '';
-
- return $reply eq 'HELO' ? Apache2::Const::OK : Apache2::Const::DECLINED;
+ if( $reply eq 'HELO' ) {
+ $socket->send("Nice to meet you\n");
+ return Apache2::Const::OK;
+ }
+ return Apache2::Const::DECLINED;
}
sub login {
pgpLwB11OE5ot.pgp
Description: PGP signature
