@@ -529,26 +529,33 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
529529 proxy_info (" Received PROXYSQL STOP command\n " );
530530 ProxySQL_Admin* SPA = (ProxySQL_Admin*)pa;
531531
532+ if (admin_nostart_) {
533+ if (__sync_fetch_and_add ((uint8_t *)(&GloVars.global .nostart ), 0 )) {
534+ SPA->send_error_msg_to_client (sess, (char *)" ProxySQL MySQL and PgSQL modules are not running; cannot stop" );
535+ return false ;
536+ }
537+ }
538+
539+ char buf[32 ];
540+
532541 // ----- MySQL module stop -----
533- admin_old_wait_timeout = GloMTH->get_variable_int ((char *)" wait_timeout" );
542+ int admin_old_wait_timeout = GloMTH->get_variable_int ((char *)" wait_timeout" );
534543 GloMTH->set_variable ((char *)" wait_timeout" , (char *)" 0" );
535544 GloMTH->commit ();
536545 GloMTH->signal_all_threads (0 );
537546 GloMTH->stop_listeners ();
538- char buf_mysql[32 ];
539- sprintf (buf_mysql, " %d" , admin_old_wait_timeout);
540- GloMTH->set_variable ((char *)" wait_timeout" , buf_mysql);
547+ sprintf (buf, " %d" , admin_old_wait_timeout);
548+ GloMTH->set_variable ((char *)" wait_timeout" , buf);
541549 GloMTH->commit ();
542550
543551 // ----- PgSQL module stop -----
544- int admin_old_wait_timeout_pgsql = GloPTH->get_variable_int ((char *)" wait_timeout" );
552+ admin_old_wait_timeout = GloPTH->get_variable_int ((char *)" wait_timeout" );
545553 GloPTH->set_variable ((char *)" wait_timeout" , (char *)" 0" );
546554 GloPTH->commit ();
547555 GloPTH->signal_all_threads (0 );
548556 GloPTH->stop_listeners ();
549- char buf_pgsql[32 ];
550- sprintf (buf_pgsql, " %d" , admin_old_wait_timeout_pgsql);
551- GloPTH->set_variable ((char *)" wait_timeout" , buf_pgsql);
557+ sprintf (buf, " %d" , admin_old_wait_timeout);
558+ GloPTH->set_variable ((char *)" wait_timeout" , buf);
552559 GloPTH->commit ();
553560
554561 // ----- Common shutdown actions -----
@@ -567,7 +574,6 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
567574 usleep (1000 );
568575 }
569576
570- // Send OK to client (important for proper disconnect behavior)
571577 SPA->send_ok_msg_to_client (sess, NULL , 0 , query_no_space);
572578
573579 return false ;
@@ -655,7 +661,6 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
655661 // GloMTH->set_variable((char *)"poll_timeout",buf);
656662 // GloMTH->commit();
657663 admin_proxysql_mysql_paused=false ;
658- // SPA->send_ok_msg_to_client(sess, NULL, 0, query_no_space);
659664 // we now rollback poll_timeout
660665 char buf[32 ];
661666 sprintf (buf," %d" ,admin_old_wait_timeout);
@@ -676,7 +681,6 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
676681 // GloPTH->set_variable((char *)"poll_timeout",buf);
677682 // GloPTH->commit();
678683 admin_proxysql_pgsql_paused = false ;
679- // SPA->send_ok_msg_to_client(sess, NULL, 0, query_no_space);
680684 // we now rollback poll_timeout
681685 char buf[32 ];
682686 sprintf (buf, " %d" , admin_old_wait_timeout);
@@ -4124,8 +4128,14 @@ void admin_session_handler(S* sess, void *_pa, PtrSize_t *pkt) {
41244128 pthread_mutex_unlock (&pa->sql_query_global_mutex );
41254129 } else {
41264130 // The admin module may have already been freed in case of "PROXYSQL STOP"
4127- if (strcasecmp (" PROXYSQL STOP" ,query_no_space))
4131+ if (strcasecmp (query_no_space, " PROXYSQL STOP" ) == 0 ) {
4132+ // Command is "PROXYSQL STOP"
4133+ if (admin_nostart_ && __sync_fetch_and_add ((uint8_t *)&GloVars.global .nostart , 0 )) {
4134+ pthread_mutex_unlock (&pa->sql_query_global_mutex );
4135+ }
4136+ } else {
41284137 pthread_mutex_unlock (&pa->sql_query_global_mutex );
4138+ }
41294139 }
41304140 l_free (pkt->size -sizeof (mysql_hdr),query_no_space); // it is always freed here
41314141 l_free (query_length,query);
0 commit comments