PerlProcessConnectionHandler doesn"t respond directly

PerlProcessConnectionHandler doesn"t respond directly

am 11.01.2008 14:11:56 von dirk.van.der.zee

Hi All,

I have written a POP3 protocol-handler which uses the=20
PerlProcessConnectionHandler. The solution worked fine under=20
Apache 2.0 and ModPerl 2.0, but after an upgrade to=20
Apache 2.2 and Mod_Perl 2.0.2 it doesn't work correctly.=20
(We upgraded from Ubuntu-Dapper to Ubuntu-Gutsy).

Specifically the problem is that the "sub handler" gets called=20
only after the client sends a linefeed. In the old situation=20
the handler started directly. The POP3 protocol needs a "+OK" response
after the connection has been established.

I have tried to make a minimal routine that only responds "hello"
(see below), but it has the same problem.

Looking on the Internet I have found one (and only one) similar problem:
http://grokbase.com/topic/2006/11/17/apache-qpsmtpd-troubles /7uFbEtSLsqURl19-7c3qhX5O7g0=20
(check the last reply).

I am out of options. Does anyone have an idea?


Thanks,
Dirk

Below is our Apache configuration and the module to return "Hello".

The virtual Apache configuration:


Order Deny,Allow
Allow from all

PerlModule ewise::EwisePop3Login
PerlProcessConnectionHandler ewise::EwisePop3Login
CustomLog /data/logs/EwisePop3Login.log combined


The package:
package ewise::EwisePop3Login;

BEGIN {
=09unshift @INC, "/data/EWISE/lib";
}
use strict;
use warnings FATAL =3D> 'all';
use Apache2::Connection ();
use APR::Socket ();
use Apache2::Const -compile =3D> 'OK';
use APR::Const -compile =3D> 'SO_NONBLOCK';

use constant BUFF_LEN =3D> 1024;
use constant REMOTE_IP=3D>'84.53.99.250';

sub handler {
=09my $c =3D shift;
=09my $sock =3D $c->client_socket;
=09my $userName;
=09$sock->send("Hello\n");
=09Apache2::Const::OK;
}

1;

Re: PerlProcessConnectionHandler doesn"t respond directly

am 22.01.2008 10:45:02 von gozer

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig38C58DAF8A596C9D4F1683E5
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: quoted-printable

Dirk van der Zee wrote:
> Hi All,
>=20
> I have written a POP3 protocol-handler which uses the=20
> PerlProcessConnectionHandler. The solution worked fine under=20
> Apache 2.0 and ModPerl 2.0, but after an upgrade to=20
> Apache 2.2 and Mod_Perl 2.0.2 it doesn't work correctly.=20
> (We upgraded from Ubuntu-Dapper to Ubuntu-Gutsy).

That's could be because since Apache 2.0.49, you have need to
set the socket to blocking mode explicitely.

From the test suite:

# starting from Apache 2.0.49 several platforms require you to set
# the socket to a blocking IO mode
my $nonblocking =3D $socket->opt_get(APR::Const::SO_NONBLOCK);
if ($nonblocking) {
$socket->opt_set(APR::Const::SO_NONBLOCK, 0);

# test that we really *are* in the blocking mode
!$socket->opt_get(APR::Const::SO_NONBLOCK)
or die "failed to set blocking mode";
}

> Specifically the problem is that the "sub handler" gets called=20
> only after the client sends a linefeed. In the old situation=20
> the handler started directly. The POP3 protocol needs a "+OK" response
> after the connection has been established.

Are you sure of that, I would think your handler gets called, just that
the $sock->send() gets buffered incorrectly, and not sent to the client
yet.

--=20
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/


--------------enig38C58DAF8A596C9D4F1683E5
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHlbsfyzKhB4jDpaURAm3RAKCXo3TpAGV4o3U3SuLR5uLd3l6+VQCg hxjH
vTf98c5pyziQxjqW4TI7U/Q=
=gX9y
-----END PGP SIGNATURE-----

--------------enig38C58DAF8A596C9D4F1683E5--