[imp] imp-2.2.3 problem

Ari Heikkinen aheikin@phaser-atm.pspt.fi
Tue, 10 Oct 2000 17:02:23 +0300 (EEST)


On Tue, 10 Oct 2000, Brent J. Nordquist wrote:

> On Tue, 10 Oct 2000, Ari Heikkinen <aheikin@phaser-atm.pspt.fi> wrote:
> 
> > After logging on IMP (with POP3) when I click on a mail to view it, then
> > quickly click "Back to INBOX", select another mail and do the same a few
> > times I get logged off the system (to the login screen) with message:
> > 
> > "Either you have logged in incorrectly or your login has expired. Please
> > login again."
> > 
> > I remember there was a race condition bug that caused it on imp-2.2.2
> 
> OK, I want to make sure we're talking about the same thing.
> 
> (1)  Are you using MySQL?

I'm using mysql from redhat-7 updates (version is 3.23.24-1).

> Are you talking about the race condition in
> 2.2.2 and earlier that produced the error message:
> 
> Database error (HordeDB): Invalid SQL: insert into active_sessions
> 
> ...followed by "Session freeze failed"?

Yes, although mentioning this "race condition" was just guessing
from my part..

> (3)  How did you solve the problem in 2.2.2 (did you apply a patch that
> changed INSERT to REPLACE, for example)?  If you apply the same change to
> 2.2.3, does it solve your problem?

Solved "Session freeze failed" on imp-2.2.2 by applying that "replace" 
patch (manually), but it doesn't seem to fix the "logout" problem I'm
currently having with imp-2.2.3.

Here are the changes I tried for phplib's ct_sql.inc on my current setup:
-----------------------------------------------------------------------------
--- ct_sql.inc.original Tue Oct 10 13:25:40 2000
+++ ct_sql.inc  Tue Oct 10 13:29:12 2000
@@ -71,13 +71,7 @@
     $name = addslashes($name);
 
     $now = date("YmdHis", time());
-    $uquery = sprintf("update %s set val='%s', changed='%s' where sid='%s' and name='%s'",
-      $this->database_table,
-      $str,
-      $now,
-      $id,
-      $name);
-    $iquery = sprintf("insert into %s ( sid, name, val, changed ) values ('%s', '%s', '%s', '%s')",
+    $iquery = sprintf("replace into %s ( sid, name, val, changed ) values ('%s', '%s', '%s', '%s')",
       $this->database_table,
       $id,
       $name,
@@ -87,9 +81,7 @@
     # This may look wierd, but SELECTing first and then doing the
     # right thing would nonatomic (in MySQL, where we cannot SELECT
     # FOR UPDATE). This is nonatomic, too, but keeps the window small.
-    $this->db->query($uquery);
-    if (  $this->db->affected_rows() == 0 
-      && !$this->db->query($iquery)) {
+    if (!$this->db->query($iquery)) {
         $ret = false;
     }
     return $ret;
-----------------------------------------------------------------------------

...but this doesn't seem to solve the problem.

> Thanks for helping us diagnose this one!

Hope this helps and keep up the good work!

> Brent J. Nordquist <bjn@horde.org>

Ari Heikkinen - PSPT <e-mail: aheikin@dlr.pspt.fi>