@@ -1526,7 +1526,7 @@ void Wsrep_schema::clear_allowlist()
1526
1526
WSREP_ERROR (" Unable to get thd" );
1527
1527
return ;
1528
1528
}
1529
- my_thread_init ();
1529
+
1530
1530
thd->thread_stack = (char *)&thd;
1531
1531
wsrep_init_thd_for_schema (thd);
1532
1532
TABLE* allowlist_table= 0 ;
@@ -1562,7 +1562,6 @@ void Wsrep_schema::clear_allowlist()
1562
1562
Wsrep_schema_impl::finish_stmt (thd);
1563
1563
out:
1564
1564
delete thd;
1565
- my_thread_end ();
1566
1565
}
1567
1566
1568
1567
void Wsrep_schema::store_allowlist (std::vector<std::string>& ip_allowlist)
@@ -1573,7 +1572,7 @@ void Wsrep_schema::store_allowlist(std::vector<std::string>& ip_allowlist)
1573
1572
WSREP_ERROR (" Unable to get thd" );
1574
1573
return ;
1575
1574
}
1576
- my_thread_init ();
1575
+
1577
1576
thd->thread_stack = (char *)&thd;
1578
1577
wsrep_init_thd_for_schema (thd);
1579
1578
TABLE* allowlist_table= 0 ;
@@ -1604,38 +1603,41 @@ void Wsrep_schema::store_allowlist(std::vector<std::string>& ip_allowlist)
1604
1603
Wsrep_schema_impl::finish_stmt (thd);
1605
1604
out:
1606
1605
delete thd;
1607
- my_thread_end ();
1608
1606
}
1609
1607
1610
- bool Wsrep_schema::allowlist_check (Wsrep_allowlist_key key,
1611
- const std::string& value)
1608
+ typedef struct Allowlist_check_arg
1612
1609
{
1613
- // We don't have wsrep schema initialized at this point
1614
- if (wsrep_schema_ready == false )
1610
+ Allowlist_check_arg (const std::string& value)
1611
+ : value(value)
1612
+ , response(false )
1615
1613
{
1616
- return true ;
1617
- }
1618
- THD *thd = new THD (next_thread_id ());
1619
- if (!thd)
1620
- {
1621
- WSREP_ERROR (" Unable to get thd" );
1622
- return false ;
1623
1614
}
1615
+ std::string value;
1616
+ bool response;
1617
+ } Allowlist_check_arg;
1618
+
1619
+ static void *allowlist_check_thread (void *param)
1620
+ {
1621
+ Allowlist_check_arg *arg= (Allowlist_check_arg *) param;
1622
+
1624
1623
my_thread_init ();
1625
- thd->thread_stack = (char *)&thd;
1624
+ THD thd (0 );
1625
+ thd.thread_stack = (char *) &thd;
1626
+ wsrep_init_thd_for_schema (&thd);
1627
+
1626
1628
int error;
1627
1629
TABLE *allowlist_table= 0 ;
1628
1630
bool match_found_or_empty= false ;
1629
1631
bool table_have_rows= false ;
1630
- char row[64 ]= { 0 , };
1631
- wsrep_init_thd_for_schema (thd);
1632
+ char row[64 ]= {
1633
+ 0 ,
1634
+ };
1632
1635
1633
1636
/*
1634
1637
* Read allowlist table
1635
1638
*/
1636
- Wsrep_schema_impl::init_stmt (thd);
1637
- if (Wsrep_schema_impl::open_for_read (thd,
1638
- allowlist_table_str.c_str (),
1639
+ Wsrep_schema_impl::init_stmt (&thd);
1640
+ if (Wsrep_schema_impl::open_for_read (&thd, allowlist_table_str.c_str (),
1639
1641
&allowlist_table) ||
1640
1642
Wsrep_schema_impl::init_for_scan (allowlist_table))
1641
1643
{
@@ -1650,7 +1652,7 @@ bool Wsrep_schema::allowlist_check(Wsrep_allowlist_key key,
1650
1652
goto out;
1651
1653
}
1652
1654
table_have_rows= true ;
1653
- if (!value.compare (row))
1655
+ if (!arg-> value .compare (row))
1654
1656
{
1655
1657
match_found_or_empty= true ;
1656
1658
break ;
@@ -1675,10 +1677,34 @@ bool Wsrep_schema::allowlist_check(Wsrep_allowlist_key key,
1675
1677
{
1676
1678
goto out;
1677
1679
}
1678
- Wsrep_schema_impl::finish_stmt (thd);
1679
- (void )trans_commit (thd);
1680
+ Wsrep_schema_impl::finish_stmt (& thd);
1681
+ (void ) trans_commit (& thd);
1680
1682
out:
1681
- delete thd;
1682
1683
my_thread_end ();
1683
- return match_found_or_empty;
1684
+ arg->response = match_found_or_empty;
1685
+ return 0 ;
1686
+ }
1687
+
1688
+ bool Wsrep_schema::allowlist_check (Wsrep_allowlist_key key,
1689
+ const std::string &value)
1690
+ {
1691
+ // We don't have wsrep schema initialized at this point
1692
+ if (wsrep_schema_ready == false )
1693
+ {
1694
+ return true ;
1695
+ }
1696
+ pthread_t allowlist_check_thd;
1697
+ int ret;
1698
+ Allowlist_check_arg arg (value);
1699
+ ret= mysql_thread_create (0 , /* Not instrumented */
1700
+ &allowlist_check_thd, NULL ,
1701
+ allowlist_check_thread, &arg);
1702
+ if (ret)
1703
+ {
1704
+ WSREP_ERROR (" allowlist_check(): mysql_thread_create() failed: %d (%s)" ,
1705
+ ret, strerror (ret));
1706
+ return false ;
1707
+ }
1708
+ pthread_join (allowlist_check_thd, NULL );
1709
+ return arg.response ;
1684
1710
}
0 commit comments