How to set a timeout for MySQL query using C API

前端 未结 4 1484
执笔经年
执笔经年 2021-01-02 15:33

I know there are lots of similar questions here, also there are lots of results, when I google it, but none of them answers my question. I read this, this, this and this but

4条回答
  •  走了就别回头了
    2021-01-02 16:22

    If you don't mind using threads, you could start the query from a new thread and have the main thread perform a short pthread_cond_timedwait for the new thread to set a condition variable that it make the connection. Then you can let the thread linger around until the actual mysql call times out. Just make sure it's detached so its resources get freed when it finally does time out. This solution isn't pretty, but it should at least work.

提交回复
热议问题