When executing a query using mysql_real_query(), if the machine on which the MySQL server is running is disconnected from the network, then it takes a lot of time for mysql_real_query() to return back, ~ 20 mins.
I am attaching the sample program here. The sample program uses the persistent connection and executes the query after every 1 minute.
Command to compile:
g++ -o mysqlsample mysqlsample.cpp -lmariadbclient -lpthread -lssl -lcrypto -L./lib -I./mysql -ldl
Command to run:
MariaDB C client library version: 2.3.3
Disable the network after the query execution and then the next query execution will take ~20mins to return.