From: Hannes Reinecke <h...@suse.de>

valgrind detected a race condition in the nic receive loop.

Signed-off-by: Hannes Reinecke <h...@suse.de>
Acked-by: Lee Duncan <ldun...@suse.com>
---
 iscsiuio/src/unix/nic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/iscsiuio/src/unix/nic.c b/iscsiuio/src/unix/nic.c
index 2fe00f1dbfa0..74b7c5e385ea 100644
--- a/iscsiuio/src/unix/nic.c
+++ b/iscsiuio/src/unix/nic.c
@@ -1491,13 +1491,13 @@ void *nic_loop(void *arg)
 
                /*  Signal that the device enable is done */
                pthread_cond_broadcast(&nic->enable_done_cond);
-               pthread_mutex_unlock(&nic->nic_mutex);
 
                LOG_INFO(PFX "%s: entering main nic loop", nic->log_name);
 
                while ((nic->state == NIC_RUNNING) &&
                       (event_loop_stop == 0) &&
                       !(nic->flags & NIC_GOING_DOWN)) {
+                       pthread_mutex_unlock(&nic->nic_mutex);
                        /*  Check the periodic and ARP timer */
                        check_timers(nic, &periodic_timer, &arp_timer);
                        rc = nic_process_intr(nic, 0);
@@ -1508,6 +1508,7 @@ void *nic_loop(void *arg)
                                                     &periodic_timer,
                                                     &arp_timer, NULL);
                        }
+                       pthread_mutex_lock(&nic->nic_mutex);
                }
 
                LOG_INFO(PFX "%s: exited main processing loop", nic->log_name);
@@ -1515,7 +1516,6 @@ void *nic_loop(void *arg)
 dev_close_free:
                free_free_queue(nic);
 dev_close:
-               pthread_mutex_lock(&nic->nic_mutex);
 
                if (nic->flags & NIC_GOING_DOWN) {
                        nic_close(nic, 1, FREE_NO_STRINGS);
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to