diff --git a/lib/Standard_ProxySQL_Admin.cpp b/lib/Standard_ProxySQL_Admin.cpp index e85c1942b..9fb5245ac 100644 --- a/lib/Standard_ProxySQL_Admin.cpp +++ b/lib/Standard_ProxySQL_Admin.cpp @@ -196,58 +196,63 @@ void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *p //fprintf(stderr,"%s----\n",query_no_space); - if (query_no_space_length==strlen("PROXYSQL START") && !strncasecmp("PROXYSQL START",query_no_space, query_no_space_length)) { - run_query=false; - Standard_ProxySQL_Admin *SPA=(Standard_ProxySQL_Admin *)pa; - bool rc=false; - if (nostart_) { - rc=__sync_bool_compare_and_swap(&GloVars.global.nostart,1,0); - } - if (rc) { - //nostart_=false; - SPA->send_MySQL_OK(&sess->myprot_client, NULL); - } else { - SPA->send_MySQL_ERR(&sess->myprot_client, (char *)"ProxySQL already started"); - } - goto __run_query; - } - - if (query_no_space_length==strlen("SHOW TABLES") && !strncasecmp("SHOW TABLES",query_no_space, query_no_space_length)) { - l_free(query_length,query); - query=l_strdup("SELECT name AS tables FROM sqlite_master WHERE type='table'"); - query_length=strlen(query)+1; - goto __run_query; - } - - if (query_no_space_length==strlen("PROXYSQL RESTART") && !strncasecmp("PROXYSQL RESTART",query_no_space, query_no_space_length)) { - run_query=false; - __sync_bool_compare_and_swap(&glovars.shutdown,0,1); - glovars.reload=1; - goto __run_query; - } - - if (query_no_space_length==strlen("PROXYSQL STOP") && !strncasecmp("PROXYSQL STOP",query_no_space, query_no_space_length)) { - run_query=false; - __sync_bool_compare_and_swap(&glovars.shutdown,0,1); - glovars.reload=2; - goto __run_query; - } - - if (query_no_space_length==strlen("PROXYSQL SHUTDOWN") && !strncasecmp("PROXYSQL SHUTDOWN",query_no_space, query_no_space_length)) { - run_query=false; - __sync_bool_compare_and_swap(&glovars.shutdown,0,1); - glovars.reload=0; - goto __run_query; - } - if (query_no_space_length==strlen("PROXYSQL KILL") && !strncasecmp("PROXYSQL KILL",query_no_space, query_no_space_length)) { - exit(EXIT_SUCCESS); - } + if ((query_no_space_length>8) && (!strncmp("PROXYSQL ", query_no_space, 8))) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL command\n"); + if (query_no_space_length==strlen("PROXYSQL START") && !strncasecmp("PROXYSQL START",query_no_space, query_no_space_length)) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL START command\n"); + run_query=false; + Standard_ProxySQL_Admin *SPA=(Standard_ProxySQL_Admin *)pa; + bool rc=false; + if (nostart_) { + rc=__sync_bool_compare_and_swap(&GloVars.global.nostart,1,0); + } + if (rc) { + //nostart_=false; + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Starting ProxySQL following PROXYSQL START command\n"); + SPA->send_MySQL_OK(&sess->myprot_client, NULL); + } else { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "ProxySQL was already started when received PROXYSQL START command\n"); + SPA->send_MySQL_ERR(&sess->myprot_client, (char *)"ProxySQL already started"); + } + goto __run_query; + } - if (query_no_space_length==strlen("SHOW TABLES") && !strncasecmp("SHOW TABLES",query_no_space, query_no_space_length)) { - l_free(query_length,query); - query=l_strdup("SELECT name AS tables FROM sqlite_master WHERE type='table'"); - query_length=strlen(query)+1; + if (query_no_space_length==strlen("PROXYSQL RESTART") && !strncasecmp("PROXYSQL RESTART",query_no_space, query_no_space_length)) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL RESTART command\n"); + run_query=false; + __sync_bool_compare_and_swap(&glovars.shutdown,0,1); + glovars.reload=1; + goto __run_query; + } + + if (query_no_space_length==strlen("PROXYSQL STOP") && !strncasecmp("PROXYSQL STOP",query_no_space, query_no_space_length)) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL STOP command\n"); + run_query=false; + __sync_bool_compare_and_swap(&glovars.shutdown,0,1); + glovars.reload=2; + goto __run_query; + } + + if (query_no_space_length==strlen("PROXYSQL SHUTDOWN") && !strncasecmp("PROXYSQL SHUTDOWN",query_no_space, query_no_space_length)) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL SHUTDOWN command\n"); + run_query=false; + __sync_bool_compare_and_swap(&glovars.shutdown,0,1); + glovars.reload=0; + goto __run_query; + } + + if (query_no_space_length==strlen("PROXYSQL KILL") && !strncasecmp("PROXYSQL KILL",query_no_space, query_no_space_length)) { + proxy_debug(PROXY_DEBUG_ADMIN, 4, "Received PROXYSQL KILL command\n"); + exit(EXIT_SUCCESS); + } + + if (query_no_space_length==strlen("SHOW TABLES") && !strncasecmp("SHOW TABLES",query_no_space, query_no_space_length)) { + l_free(query_length,query); + query=l_strdup("SELECT name AS tables FROM sqlite_master WHERE type='table'"); + query_length=strlen(query)+1; + goto __run_query; + } goto __run_query; }