From 2979867a363a13e12574262d0ed0231f8a524b35 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 1 Nov 2003 05:10:49 +0000 Subject: [PATCH] * When sending the QUIT command to the server, output a bunch more newlines so the session proxy has a chance to see that the Citadel server closed the connection. This will make the proxy shut down as well. --- ctdlphp/ChangeLog | 6 ++++++ ctdlphp/ctdlsession.php | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ctdlphp/ChangeLog b/ctdlphp/ChangeLog index dac43a657..a9197843f 100644 --- a/ctdlphp/ChangeLog +++ b/ctdlphp/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 1.3 2003/11/01 05:10:49 ajc + * When sending the QUIT command to the server, output a bunch more newlines + so the session proxy has a chance to see that the Citadel server closed + the connection. This will make the proxy shut down as well. + Revision 1.2 2003/10/31 05:03:46 ajc * Stabilized the session proxy * Added 100 mode text downloads @@ -6,3 +11,4 @@ Revision 1.1 2003/10/31 03:47:13 ajc * Initial CVS import + diff --git a/ctdlphp/ctdlsession.php b/ctdlphp/ctdlsession.php index fe0e374f3..6669eac75 100644 --- a/ctdlphp/ctdlsession.php +++ b/ctdlphp/ctdlsession.php @@ -11,10 +11,15 @@ function establish_citadel_session() { global $session, $clientsocket; - // echo "Calling session_start()
\n"; - // flush(); session_start(); - $session = "CtdlSession." . session_id(); + + if ($_SESSION["ctdlsession"]) { + $session = $_SESSION["ctdlsession"]; + } + else { + $session = "CtdlSession." . time() . rand(1000,9999) ; + $_SESSION["ctdlsession"] = $session; + } // See if there's a Citadel connection proxy open for this session. // The name of the socket is identical to the name of the @@ -22,8 +27,6 @@ function establish_citadel_session() { $sockname = "/tmp/" . $session . ".socket" ; - // echo "Connecting to ", $sockname, "...
\n"; - // flush(); $clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5); if (!$clientsocket) { // It ain't there, dude. Open up the proxy. (C version) @@ -73,13 +76,16 @@ function ctdl_end_session() { global $clientsocket, $session; // Tell the Citadel server to terminate our connection. - fwrite($clientsocket, "QUIT\n"); + // (The extra newlines force it to see that the Citadel session + // ended, and the proxy will quit.) + // + fwrite($clientsocket, "QUIT\n\n\n\n\n\n\n\n\n\n\n"); $response = fgets($clientsocket, 4096); // IGnore response fclose($clientsocket); unset($clientsocket); // Now clear our PHP session. - unset($session); + $_SESSION = array(); session_write_close(); } -- 2.30.2