libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] How to avoid "mysql server has gone away"?


From: klemens
Subject: [libmicrohttpd] How to avoid "mysql server has gone away"?
Date: Sun, 12 Mar 2023 15:13:01 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

During longer idle-times of the server, when no queries to 
mysql happen, mysql is shutting down and the server stops
with the message "mysql server has gone away". I try to 
avoid this by making a "select now()" query every hour or
so, but it seems, I can't get out of the eventloop, the 
func expire_sessions() where the query is done, is never
called:

    MHD_start_daemon (  0,
                        55301,
                        &on_client_connect, myclient_ip,
                        &create_response, NULL,
                        MHD_OPTION_NOTIFY_COMPLETED, &expire_sessions, NULL,
                                                MHD_OPTION_CONNECTION_TIMEOUT, 
(unsigned int)120,
                        MHD_OPTION_CONNECTION_LIMIT, (unsigned int)50,
                        MHD_OPTION_END
                     );
    if (NULL == vbad)
        return (emsg ("Can't create daemon"));
    while (1)
    {
        expire_sessions ();
        max = 0;
        FD_ZERO (&rs);
        FD_ZERO (&ws);
                FD_ZERO (&es);
        if (MHD_YES != MHD_get_fdset (vbad, &rs, &ws, &es, &max))
            break; /* fatal internal error */
        if (MHD_get_timeout (vbad, &mhd_timeout) == MHD_YES)
        {
            tv.tv_sec = mhd_timeout / 1000;
            tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
            tvp = &tv;
        }
        else
            tvp = NULL;
        if (-1 == select (max + 1, &rs, &ws, &es, tvp))
        {
            if (EINTR != errno)
            abort ();
        }
        MHD_run (vbad);

Could anyone please point out, what I'm doing wrong here. Thanks in
advanve.

Klemens.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]