This is the block of code from libmariadb.c:
The second option of vio_wait_or_timeout() is "my_bool is_read". If set to true, it waits for a read. If set to false, it waits for a write. The code above is waiting to read a packet from the server, so it should be TRUE. However, it is false, so it waits for a write instead. Since this happens immediately after it has already waited for the connection, this always returns immediately. However, on async it passes the wrong flags (i.e. WAIT_WRITE instead of WAIT_READ) to the async caller, which messes up edge-triggered event handling. It also means that it does not actually wait for the timeout that it is supposed to be waiting for.