В сообщении от 24.10.2004 01:51 [EMAIL PROTECTED] пишет:
> I just upgraded to the latest 2.0 CVS and dbmail-imap is really slow
> compared to my old 1.X install using imapd.
> Dbmail-imapd chews up 99% cpu at the last entry of the log and seem to
> "stall" there for the 21000 item inbox:
Could you please try the attached patch and see if it fixes your
problem?
Yours, Mikhail Ramendik
--- mysql/dbmysql.c.orig 2004-06-03 16:41:55.000000000 +0400
+++ mysql/dbmysql.c 2004-10-23 16:10:31.000000000 +0400
@@ -1,6 +1,8 @@
/*
Copyright (C) 1999-2004 IC & S [EMAIL PROTECTED]
+ Modified 2004 by Mikhail Ramendik [EMAIL PROTECTED] (MR)
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
@@ -49,6 +51,11 @@
static MYSQL_RES *stored_res = NULL; /**< MySQL result set backup */
static MYSQL_ROW last_row; /**< MySQL result row */
+/* Additions by MR */
+
+static int res_changed = 1; /* result set changed */
+static unsigned last_row_number = 0; /* the number of the row in last_row */
+
/** database parameters */
db_param_t _db_params;
@@ -134,6 +141,7 @@
trace(TRACE_WARNING, "%s,%s: Trying to free result set "
"that is already NULL!", __FILE__, __func__);
res = NULL;
+ res_changed = 1; /*MR*/
}
@@ -154,9 +162,28 @@
return NULL;
}
- mysql_data_seek(res, row);
- last_row = mysql_fetch_row(res);
+ /*MR*/
+
+ if (res_changed)
+
+ {
+ mysql_data_seek(res, row);
+ last_row = mysql_fetch_row(res);
+ } else {
+ if (row == last_row_number+1)
+ last_row = mysql_fetch_row(res);
+ else if (row != last_row_number) {
+ mysql_data_seek(res, row);
+ last_row = mysql_fetch_row(res);
+ };
+ /* otherwise last_row is already loaded and does not need to change! MR*/
+ };
+ res_changed = 0;
+ last_row_number = row;
+
+ /*MR changes end here*/
+
if (last_row == NULL) {
trace(TRACE_WARNING, "%s,%s: row is NULL\n",
__FILE__, __func__);
@@ -238,6 +265,7 @@
}
res = mysql_store_result(&conn);
+ res_changed = 1; /*MR*/
return 0;
}
@@ -304,12 +332,14 @@
{
stored_res = res;
res = msgbuf_res;
+ res_changed = 1; /*MR*/
}
void db_store_msgbuf_result()
{
msgbuf_res = res;
res = stored_res;
+ res_changed = 1; /*MR*/
}
void *db_get_result_set()
@@ -320,4 +350,5 @@
void db_set_result_set(void *the_result_set)
{
res = (MYSQL_RES *) the_result_set;
+ res_changed = 1; /*MR*/
}