* When sending the QUIT command to the server, output a bunch more newlines
authorArt Cancro <ajc@citadel.org>
Sat, 1 Nov 2003 05:10:49 +0000 (05:10 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 1 Nov 2003 05:10:49 +0000 (05:10 +0000)
  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
ctdlphp/ctdlsession.php

index dac43a657bc40038026743601dd0d45472e4000d..a9197843fec29ebfbfb51e0d286241303c9a2b65 100644 (file)
@@ -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
+
index fe0e374f3e6a526e180db73bb304a1b89afa7712..6669eac75af8d4007841273844f834b4c1216050 100644 (file)
@@ -11,10 +11,15 @@ function establish_citadel_session() {
 
        global $session, $clientsocket;
 
-       // echo "Calling session_start()<BR>\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, "...<BR>\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();
 }