MDL-30026 improve session lock - stronger detection for oracle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 13 Nov 2011 18:23:53 +0000 (19:23 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 13 Nov 2011 18:23:53 +0000 (19:23 +0100)
lib/dml/oci_native_moodle_database.php

index 9af8d78..40b046c 100644 (file)
@@ -1628,16 +1628,12 @@ class oci_native_moodle_database extends moodle_database {
         $this->query_start($sql, $params, SQL_QUERY_AUX);
         $stmt = $this->parse_query($sql);
         $this->bind_params($stmt, $params);
-        $start = time();
         $result = oci_execute($stmt, $this->commit_status);
-        $end = time();
-        $this->query_end($result, $stmt);
-        oci_free_statement($stmt);
-
-        if ($end - $start >= $timeout) {
-            //TODO: there has to be a better way to find out if lock obtained
+        if ($result === false) { // Any failure in get_lock() raises error, causing return of bool false
             throw new dml_sessionwait_exception();
         }
+        $this->query_end($result, $stmt);
+        oci_free_statement($stmt);
     }
 
     public function release_session_lock($rowid) {