Paul Gofman : nsiproxy.sys: Update interface table only if LUID is not found in convert_luid_to_unix_name().

Alexandre Julliard julliard at winehq.org
Tue May 17 15:37:23 CDT 2022


Module: wine
Branch: master
Commit: 1f3c1fdbc7e4c537c2ab41d59bcaa68aa4f93567
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1f3c1fdbc7e4c537c2ab41d59bcaa68aa4f93567

Author: Paul Gofman <pgofman at codeweavers.com>
Date:   Mon May 16 16:24:45 2022 -0500

nsiproxy.sys: Update interface table only if LUID is not found in convert_luid_to_unix_name().

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/nsiproxy.sys/ndis.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c
index 929bda9cd90..9b09756f35c 100644
--- a/dlls/nsiproxy.sys/ndis.c
+++ b/dlls/nsiproxy.sys/ndis.c
@@ -286,17 +286,19 @@ static struct if_entry *add_entry( UINT index, char *name )
     return entry;
 }
 
-static void update_if_table( void )
+static unsigned int update_if_table( void )
 {
     struct if_nameindex *indices = if_nameindex(), *entry;
+    unsigned int append_count = 0;
 
     for (entry = indices; entry->if_index; entry++)
     {
-        if (!find_entry_from_index( entry->if_index ))
-            add_entry( entry->if_index, entry->if_name );
+        if (!find_entry_from_index( entry->if_index ) && add_entry( entry->if_index, entry->if_name ))
+            ++append_count;
     }
 
     if_freenameindex( indices );
+    return append_count;
 }
 
 static void if_counted_string_init( IF_COUNTED_STRING *str, const WCHAR *value )
@@ -634,18 +636,24 @@ BOOL convert_luid_to_unix_name( const NET_LUID *luid, const char **unix_name )
 {
     struct if_entry *entry;
     BOOL ret = FALSE;
+    int updated = 0;
 
     pthread_mutex_lock( &if_list_lock );
 
-    update_if_table();
-
-    LIST_FOR_EACH_ENTRY( entry, &if_list, struct if_entry, entry )
-        if (entry->if_luid.Value == luid->Value)
+    do
+    {
+        LIST_FOR_EACH_ENTRY( entry, &if_list, struct if_entry, entry )
         {
-            *unix_name = entry->if_unix_name;
-            ret = TRUE;
-            break;
+            if (entry->if_luid.Value == luid->Value)
+            {
+                *unix_name = entry->if_unix_name;
+                ret = TRUE;
+                goto done;
+            }
         }
+    } while (!updated++ && update_if_table());
+
+done:
     pthread_mutex_unlock( &if_list_lock );
 
     return ret;




More information about the wine-cvs mailing list