Merge "[FileBackend] Clear swift connection on invalid HTTP responses."
authorDemon <chadh@wikimedia.org>
Wed, 5 Sep 2012 19:14:09 +0000 (19:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 5 Sep 2012 19:14:09 +0000 (19:14 +0000)
includes/filebackend/SwiftFileBackend.php

index 88727e4..7f91ae3 100644 (file)
@@ -1218,6 +1218,19 @@ class SwiftFileBackend extends FileBackendStore {
                return $this->conn;
        }
 
+       /**
+        * Close the connection to the Swift proxy
+        *
+        * @return void
+        */
+       protected function closeConnection() {
+               if ( $this->conn ) {
+                       $this->conn->close(); // close active cURL handles in CF_Http object
+                       $this->sessionStarted = 0;
+                       $this->connContainerCache->clear();
+               }
+       }
+
        /**
         * Get the cache key for a container
         *
@@ -1331,6 +1344,7 @@ class SwiftFileBackend extends FileBackendStore {
                }
                if ( $e instanceof InvalidResponseException ) { // possibly a stale token
                        $this->srvCache->delete( $this->getCredsCacheKey( $this->auth->username ) );
+                       $this->closeConnection(); // force a re-connect and re-auth next time
                }
                wfDebugLog( 'SwiftBackend',
                        get_class( $e ) . " in '{$func}' (given '" . FormatJson::encode( $params ) . "')" .