[v4] raw/ifpga: fix pthread cannot join
Checks
Commit Message
From: Tianfei Zhang <tianfei.zhang@intel.com>
When we want to close a thread, we should set a flag to notify
thread handler function.
Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree")
Cc: stable@dpdk.org
Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
---
v2: update commit log
---
v3: set thread id to 0 after pthread_join
---
v4: do not evaluate and set pthread_t variable
---
drivers/raw/ifpga/ifpga_rawdev.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
@@ -497,7 +497,7 @@ static int set_surprise_link_check_aer(
int gsd_enable, ret;
#define MS 1000
- while (1) {
+ while (ifpga_monitor_start) {
gsd_enable = 0;
for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
ifpga_rdev = &ifpga_rawdevices[i];
@@ -542,19 +542,20 @@ static int set_surprise_link_check_aer(
static int
ifpga_monitor_stop_func(void)
{
+ void *status;
int ret;
if (ifpga_monitor_start == 1) {
+ ifpga_monitor_start = 0;
+
ret = pthread_cancel(ifpga_monitor_start_thread);
if (ret)
IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread");
- ret = pthread_join(ifpga_monitor_start_thread, NULL);
+ ret = pthread_join(ifpga_monitor_start_thread, &status);
if (ret)
IFPGA_RAWDEV_PMD_ERR("Can't join the thread");
- ifpga_monitor_start = 0;
-
return ret;
}