Bojan Smojver wrote:
On Thu, 2007-08-23 at 09:49 +0900, 玉越大輝 wrote:

Please patch the attached file to apr_dbd_mysql.c in order to make it
works with threaded mpm.

The current code works only with prework mpm.

Just ran 100,000 requests (concurrency level 5, keep-alive) against
httpd 2.2.4 with worker MPM, using apr-util 1.3.0 (trunk) and
mysql-5.0.37-2.fc7 on Fedora 7, but I can't replicate any segfaults.
MySQL was running about 90 threads and was doing both SELECT and UPDATE
operations. I did that using my own little concoction called mod_spin.

Could you give a bit more details on your setup and code that you're
running?

try adding the following snippet to your code:
Ignore 'multi' for the moment, it isn't related, but the "groups" parameter gets mysql to read some settings from the my.cnf file, so we can do things like specify the character set.

without the mysql_thread_init() call this segfaults internally in mysql code. (5.1.20 & 5.0.44).



--- apr_dbd_mysql.c     2007-10-11 06:16:32.000000000 +1000
+++ /src/httpd/trunk/srclib/apr-util/dbd/apr_dbd_mysql.c 2007-10-18 10:26:55.000000000 +1000
@@ -1457,7 +1457,9 @@
        {"port", NULL},
        {"sock", NULL},
        {"flags", NULL},
+        {"multi", NULL},
        {"fldsz", NULL},
+        {"group", NULL},
        {NULL, NULL}
    };
    unsigned int port = 0;
@@ -1498,9 +1500,20 @@
        !strcmp(fields[6].value, "CLIENT_FOUND_ROWS")) {
        flags |= CLIENT_FOUND_ROWS; /* only option we know */
    }
-    if (fields[7].value != NULL) {
+    if (fields[7].value != NULL &&
+        !strcmp(fields[7].value, "CLIENT_MULTI_STATEMENTS")) {
+        flags |= CLIENT_MULTI_STATEMENTS; /* only option we know */
+    }
+
+
+    if (fields[8].value != NULL) {
        sql->fldsz = atol(fields[7].value);
    }
+ + if (fields[9].value != NULL ) {
+
+ mysql_options(sql->conn, MYSQL_READ_DEFAULT_GROUP, fields[9].value);
+    }

#if MYSQL_VERSION_ID >= 50013
    /* the MySQL manual says this should be BEFORE mysql_real_connect */
@@ -1513,6 +1526,9 @@
                                   fields[5].value, flags);

    if(real_conn == NULL) {
+        const char* errstring;
+        errstring =mysql_error(sql->conn);
+        fprintf(stderr, "%s\n",errstring);
        mysql_close(sql->conn);
        return NULL;
    }
@@ -1582,6 +1598,8 @@
static void dbd_mysql_init(apr_pool_t *pool)
{
    my_init();
+    mysql_thread_init();
+ /* FIXME: this is a guess; find out what it really does */ apr_pool_cleanup_register(pool, NULL, thread_end, apr_pool_cleanup_null);
}

Reply via email to