← Back to team overview

maria-developers team mailing list archive

mysql_get_timeout_value returning 0 always

 

I am basing my work on the async_queries.c example.

In my code, I am calling mysql_real_connect_start(), and the return value
indicates that MySQL is waiting for READ and TIMEOUT. However, if I call
mysql_get_timeout_value() (or the _ms() version) right after that, it
returns 0. Is this expected? As far as I can see, this is causing the next
call to mysql_real_connect_cont() (which happens immediately, because the
timeout triggers right away) to return an error.

This is on OS X 10.11.6 with the MariaDB client just installed via brew;
mariadb_config --version says 5.5.1.

This is the code I'm calling:

            status = mysql_real_connect_start(&ret, &mysql, h, u, p, d, 0,
0, 0);
            printf("MYSQL connect %d", status);
            if (status & MYSQL_WAIT_TIMEOUT) {
                unsigned int ms = mysql_get_timeout_value_ms(&mysql);
                printf(" and includes a timeout of %u ms", ms);
            }
            printf("\n");

That code prints: MYSQL connect 9 and includes a timeout of 0 ms

I did find two ways to make the code work:

   1. Not passing MYSQL_WAIT_TIMEOUT back to the mysql_real_connect_cont()
   (so it thinks a timeout has not happened at all). This allows all the
   queries to actually complete, but the code ends up polling heavily.
   2. Forcing the return value of mysql_get_timeout_value_ms() to be > 0.
   This makes the code work beautifully, but of course I would rather follow
   MySQL's hint as to the timeout extension.


I would appreciate any hints as to what I am missing. Thanks much in
advance.

-- 
Gonzalo Diethelm
gonzalo.diethelm@xxxxxxxxx

Follow ups