--nextPart2167760.teguA16Ao3 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, I know, this worked once, but since a few days, it doesn't, and I do *not*= =20 know what I've changed to get this happen. Well, I have to care about early web client aborts, as well as backend serv= er=20 aborts while streaming data to the web client (I obviousely got from the=20 backend server my module is connected to, too). Well, the best way to achieve this, is, to poll on both. At very first, I've to register a pre connection hook to catch the web clie= nts=20 file descriptor. static void registerHooks(apr_pool_t *p) { ap_hook_pre_connection(getClientSocket, 0, 0, APR_HOOK_FIRST); // ... } int getClientSocket(conn_rec *conn, void *data) { apr_os_sock_get(&FClientSocket, reinterpret_cast(data)); int optval =3D 1; setsockopt(FClientSocket, SOL_SOCKET, TCP_NODELAY, &optval, sizeof(optval)); return OK; } Next, on a incoming connection, that belongs to us, I've to handle my stuff= as=20 usual *but* have to watch on early connection aborts on web client side, as= =20 well as on backend server side. void TChatStreamer::streamPageBody() { pollfd pfds[2]; pfds[0].fd =3D FWebClientSocket; pfds[0].events =3D POLLIN; pfds[1].fd =3D FBackendServerSocket; pfds[1].events =3D POLLIN; while (!FAborted) { int rv =3D poll(pfds, 2, 60 * 1000); if (rv > 0) { if (pfds[0].revents & POLLIN) FAborted =3D true; /* early client abort */ if (pfds[1].revents & POLLIN) handleEventFromServer(); /* got event from backend server */ } else if (rv =3D=3D -1) { FAborted =3D true; } else { handleTimeout(); } } logoutClientFromBackendServer(); /* when we finished job, logout webclient= */ } void TChatStreamer::handleEventFromServer() { std::string input(readLineFd(FBackendServerSocket)); if (input.empty()) handleServerAbort(); else handleEventFromServer(input); } void TChatStreamer::handleTimeout() { /* send some random HTML comment to web client in order to=20 keep connection alive */ } Well done. This is just a rarely abstract code snippet, however, I intent t= o=20 send all incoming events I get from the backend server to the web client, s= o,=20 the apache module may be understood, to act as a proxy between. Important n= ow=20 is, that the web client, that also logged in to the backend server via the= =20 apache module, needs also to logout via this. Of course, lots of user miss the logout button, and just close the webbrows= er=20 in order to sign, that they've done chatting, that is, they do *not* get an= y=20 other events (e.g. chat messages) from the backend server via the apache=20 module. So, the apache module needs to log them out automatically, at least= ,=20 let them leave the channel they've currently joined. I repeat, this worked= =20 some day before, but obviousely, actually not. And I do not know why :( Also, a problem would be, that the module would end into an infinite loop,= =20 when we cannot detect the early (web) client abort. The problem now. The code above does *not* detect a client abort, poll() -= =20 previousely select() - does not return when the client aborts the connectio= n.=20 And even more *worse*, when the backend server disconnects its (apache)=20 clients (e.g. via shutdown), the apache module's request handler just notic= es=20 this, *BUT* also notices a client abort, that - of course - was not true. This is strange, but why? What could have been the problem here? So, when the backend server (int FBackendServerFd) closes connection, I get= =20 notified via poll() to have *two* closed connections, the backend server=20 *AND* the webclient. When I close the connection of the webbrowser (by just closing it), I get e= ven=20 nothing =3D> the webserver's request handler runs into infinite loop =3D> t= he=20 backend server can't get notified about the real dead (web) client =3D> we'= ve=20 lots of dead ppl in the chat I've to kick each day ;-) I'd be really really happy, if anyone could give me any hint he has to fix= =20 this issue. Regards, Christian Parpart. =2D-=20 15:56:10 up 16 days, 3:35, 0 users, load average: 0.52, 0.43, 0.38 --nextPart2167760.teguA16Ao3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBQGbVPpa2GmDVhK0RAiMPAJ44HUMGkwvgtwdeHkfx+rLg2skdwwCaAt1P kpgCTBYuA98V7pp25e5Bu00= =ygK/ -----END PGP SIGNATURE----- --nextPart2167760.teguA16Ao3--