[vlc-commits] [Git][videolan/vlc][3.0.x] 9 commits: dsm: forward the vlc_interrupt_unregister() return value

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Wed Jun 22 14:29:08 UTC 2022



Rémi Denis-Courmont pushed to branch 3.0.x at VideoLAN / VLC


Commits:
e85012d0 by Thomas Guillem at 2022-06-22T07:41:38+00:00
dsm: forward the vlc_interrupt_unregister() return value

(cherry picked from commit 26af61217bf0d8cd85aa811a98ec403a0951a29c)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
f026d55f by Thomas Guillem at 2022-06-22T07:41:38+00:00
dsm: handle missing smb_session interruptions

(cherry picked from commit bdc351dfe5df180dcacda06e54527f9c8d04226d)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
0a912764 by Thomas Guillem at 2022-06-22T07:41:38+00:00
dsm: abort if netbios_ns_inverse is interrupted

(cherry picked from commit 30eb1b27cde532d8c9ab6dee2f4cc6cdd1cdcf41)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
6136d0e5 by Thomas Guillem at 2022-06-22T07:41:38+00:00
contrib: libdsm: update to 0.4.3

Fix connect() not interruptible on Linux.

Fixes #27027

(cherry picked from commit 7ea6ce343341a4170234364f80987bbd7f64d005)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
f7ff0361 by Thomas Guillem at 2022-06-22T07:41:38+00:00
smb2: vlc_smb2_resolve: return an error code

(cherry picked from commit cbf16982cfa4457bd2f319e5d399e0455c512a16)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
a2d42008 by Thomas Guillem at 2022-06-22T07:41:38+00:00
smb2: forward the vlc_interrupt_unregister() return value

(cherry picked from commit 99a4deaf06ae57383fc887ec976f1e510aef6978)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
9c3dacd9 by Thomas Guillem at 2022-06-22T07:41:38+00:00
smb2: vlc_smb2_resolve: return -EINTR when interrupted

(cherry picked from commit bb33734cdf2a0f1f5ea19e42b6596208395ea1f3)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
20374d30 by Thomas Guillem at 2022-06-22T07:41:38+00:00
smb2: handle vlc_smb2_resolve interruption

(cherry picked from commit fea7a18a91cee9edaf629589980bff5ea0192573)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -
68e5d977 by Thomas Guillem at 2022-06-22T07:41:38+00:00
smb2: explicitly handle -EINTR

Even if it is redundant with vlc_killed() (but not all APIs return
-EINTR when killed).

(cherry picked from commit 797e1f3b979fca463030608db1513a81228c624c)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -


4 changed files:

- contrib/src/libdsm/SHA512SUMS
- contrib/src/libdsm/rules.mak
- modules/access/dsm/access.c
- modules/access/smb2.c


Changes:

=====================================
contrib/src/libdsm/SHA512SUMS
=====================================
@@ -1 +1 @@
-9ee82c8812a807054ebe3ceb2a6ba37c36d188052cfbd7f5ba5b435ede8f6bee09690fb0d0c94e1e4d0022bbbdfa2837f09c69ccc00d17f79efe002cc158825a  libdsm-0.4.2.tar.xz
+4abe2318aa5d63397404ce87fc42be30d364dffef3bdf6e081a2bb3ac4f011f39fa8acb5ba06361e94795a308df321b077e7a3cf2ec10d5e1e6c9b912cbbd8ba  libdsm-0.4.3.tar.xz


=====================================
contrib/src/libdsm/rules.mak
=====================================
@@ -1,6 +1,6 @@
 # libdsm
 
-LIBDSM_VERSION := 0.4.2
+LIBDSM_VERSION := 0.4.3
 LIBDSM_URL := https://github.com/videolabs/libdsm/releases/download/v$(LIBDSM_VERSION)/libdsm-$(LIBDSM_VERSION).tar.xz
 
 ifeq ($(call need_pkg,"libdsm >= 0.2.0"),)


=====================================
modules/access/dsm/access.c
=====================================
@@ -149,10 +149,10 @@ smb_session_interrupt_register( access_sys_t *sys )
     vlc_interrupt_register( smb_session_interrupt_callback, sys->p_session );
 }
 
-static inline void
+static inline int
 smb_session_interrupt_unregister( void )
 {
-    vlc_interrupt_unregister();
+    return vlc_interrupt_unregister();
 }
 
 static void
@@ -167,18 +167,37 @@ netbios_ns_interrupt_register( netbios_ns *ns )
     vlc_interrupt_register( netbios_ns_interrupt_callback, ns );
 }
 
-static inline void
+static inline int
 netbios_ns_interrupt_unregister( void )
 {
-    vlc_interrupt_unregister();
+    return vlc_interrupt_unregister();
 }
 
 #else
 
-#define smb_session_interrupt_register( sys ) do {} while (0)
-#define smb_session_interrupt_unregister() do {} while(0)
-#define netbios_ns_interrupt_register( ns ) do {} while (0)
-#define netbios_ns_interrupt_unregister() do {} while (0)
+static inline void
+smb_session_interrupt_register( access_sys_t *sys )
+{
+    (void) sys;
+}
+
+static inline int
+smb_session_interrupt_unregister( void )
+{
+    return 0;
+}
+
+static inline void
+netbios_ns_interrupt_register( netbios_ns *ns )
+{
+    (void) ns;
+}
+
+static inline int
+netbios_ns_interrupt_unregister( void )
+{
+    return 0;
+}
 
 #endif
 
@@ -239,11 +258,13 @@ static int Open( vlc_object_t *p_this )
     if( smb_stat_get( st, SMB_STAT_ISDIR ) )
     {
         smb_fclose( p_sys->p_session, p_sys->i_fd );
-        smb_session_interrupt_unregister();
+        if (smb_session_interrupt_unregister() == EINTR)
+            goto error;
         return BrowserInit( p_access );
     }
 
-    smb_session_interrupt_unregister();
+    if (smb_session_interrupt_unregister() == EINTR)
+        goto error;
 
     msg_Dbg( p_access, "Successfully opened smb://%s", p_access->psz_location );
 
@@ -322,7 +343,11 @@ static int get_address( stream_t *p_access )
 
         int ret = netbios_ns_resolve( p_ns, p_sys->url.psz_host,
                                       NETBIOS_FILESERVER, &ip4_addr);
-        netbios_ns_interrupt_unregister();
+        if (netbios_ns_interrupt_unregister() == EINTR)
+        {
+            netbios_ns_destroy( p_ns );
+            return -EINTR;
+        }
         netbios_ns_destroy( p_ns );
 
         if( ret == 0 )
@@ -359,6 +384,11 @@ static int get_address( stream_t *p_access )
     const char *psz_nbt = netbios_ns_inverse( p_ns, p_sys->addr.s_addr );
 
     netbios_ns_interrupt_unregister();
+    if (netbios_ns_interrupt_unregister() == EINTR)
+    {
+        netbios_ns_destroy( p_ns );
+        return -EINTR;
+    }
     netbios_ns_destroy( p_ns );
 
     if( psz_nbt != NULL )
@@ -459,7 +489,8 @@ static int login( stream_t *p_access )
         goto error;
     }
 
-    smb_session_interrupt_unregister();
+    if (smb_session_interrupt_unregister() == EINTR)
+        goto error;
 
     if( connect_err == EACCES )
     {
@@ -602,7 +633,8 @@ static ssize_t Read( stream_t *p_access, void *p_buffer, size_t i_len )
 
     smb_session_interrupt_register( p_sys );
     i_read = smb_fread( p_sys->p_session, p_sys->i_fd, p_buffer, i_len );
-    smb_session_interrupt_unregister();
+    if (smb_session_interrupt_unregister() == EINTR)
+        errno = EINTR;
 
     if( i_read < 0 )
     {


=====================================
modules/access/smb2.c
=====================================
@@ -65,16 +65,26 @@ netbios_ns_interrupt_register(netbios_ns *ns)
     vlc_interrupt_register(netbios_ns_interrupt_callback, ns);
 }
 
-static inline void
+static inline int
 netbios_ns_interrupt_unregister(void)
 {
-    vlc_interrupt_unregister();
+    return vlc_interrupt_unregister();
 }
 
 #else
 
-#define netbios_ns_interrupt_register( ns ) do {} while (0)
-#define netbios_ns_interrupt_unregister() do {} while (0)
+static inline void
+netbios_ns_interrupt_register(netbios_ns *ns)
+{
+    (void) ns;
+}
+
+static inline int
+netbios_ns_interrupt_unregister(void)
+{
+    return 0;
+}
+
 #endif
 
 #endif
@@ -734,18 +744,19 @@ error:
     return op.error_status;
 }
 
-static char *
-vlc_smb2_resolve(stream_t *access, const char *host, unsigned port)
+static int
+vlc_smb2_resolve(stream_t *access, const char *host, unsigned port,
+                 char **out_host)
 {
     (void) access;
     if (!host)
-        return NULL;
+        return -ENOENT;
 
 #ifdef HAVE_DSM
     /* Test if the host is an IP */
     struct in_addr addr;
     if (inet_pton(AF_INET, host, &addr) == 1)
-        return NULL;
+        return -ENOENT;
 
     /* Test if the host can be resolved */
     struct addrinfo *info = NULL;
@@ -753,28 +764,38 @@ vlc_smb2_resolve(stream_t *access, const char *host, unsigned port)
     {
         freeaddrinfo(info);
         /* Let smb2 resolve it */
-        return NULL;
+        return -ENOENT;
     }
 
     /* Test if the host is a netbios name */
-    char *out_host = NULL;
     netbios_ns *ns = netbios_ns_new();
     if (!ns)
-        return NULL;
+        return -ENOMEM;
+
+    int ret = -ENOENT;
     netbios_ns_interrupt_register(ns);
     uint32_t ip4_addr;
     if (netbios_ns_resolve(ns, host, NETBIOS_FILESERVER, &ip4_addr) == 0)
     {
         char ip[INET_ADDRSTRLEN];
         if (inet_ntop(AF_INET, &ip4_addr, ip, sizeof(ip)))
-            out_host = strdup(ip);
+        {
+            *out_host = strdup(ip);
+            ret = 0;
+        }
+    }
+    if (netbios_ns_interrupt_unregister() == EINTR)
+    {
+        if (unlikely(ret == 0))
+            free(*out_host);
+        netbios_ns_destroy(ns);
+        return -EINTR;
     }
-    netbios_ns_interrupt_unregister();
     netbios_ns_destroy(ns);
-    return out_host;
+    return ret;
 #else
     (void) port;
-    return NULL;
+    return -ENOENT;
 #endif
 }
 
@@ -797,13 +818,16 @@ Open(vlc_object_t *p_obj)
     if (sys->encoded_url.psz_path == NULL)
         sys->encoded_url.psz_path = (char *) "/";
 
-    char *resolved_host = vlc_smb2_resolve(access, sys->encoded_url.psz_host,
-                                           sys->encoded_url.i_port);
+    char *resolved_host = NULL;
+    ret = vlc_smb2_resolve(access, sys->encoded_url.psz_host,
+                           sys->encoded_url.i_port, &resolved_host);
 
     /* smb2_* functions need a decoded url. Re compose the url from the
      * modified sys->encoded_url (with the resolved host). */
     char *url;
-    if (resolved_host != NULL)
+    if (ret == -EINTR)
+        goto error;
+    else if (ret == 0)
     {
         vlc_url_t resolved_url = sys->encoded_url;
         resolved_url.psz_host = resolved_host;
@@ -892,7 +916,7 @@ error:
      * case of network error (EIO) or when the user asked to cancel it
      * (vlc_killed()). Indeed, in these cases, it is useless to try next smb
      * modules. */
-    return vlc_killed() || ret == -EIO ? VLC_ETIMEOUT : VLC_EGENERIC;
+    return ret == -EINTR || ret == -EIO || vlc_killed() ? VLC_ETIMEOUT : VLC_EGENERIC;
 }
 
 static void



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8e5e07661fe5baab92d97230b8226ba47ef3540d...68e5d977277f874861916286b4dcc58535a9f7a0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8e5e07661fe5baab92d97230b8226ba47ef3540d...68e5d977277f874861916286b4dcc58535a9f7a0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list