[vlc-commits] [Git][videolan/vlc][master] 5 commits: contrib: libdsm: update to 0.4.0

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Mar 5 04:12:46 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
305eae38 by Thomas Guillem at 2022-03-05T02:10:49+00:00
contrib: libdsm: update to 0.4.0

And switch to meson.

- - - - -
36ab008e by Thomas Guillem at 2022-03-05T02:10:49+00:00
dsm: make the smb_session interruptible

- - - - -
d0ffce0f by Thomas Guillem at 2022-03-05T02:10:49+00:00
dsm: reduce netbios_ns lifetime

It's only needed from get_address(), from Open().

- - - - -
088e3783 by Thomas Guillem at 2022-03-05T02:10:49+00:00
dsm: make netbios_ns interruptible

- - - - -
f0c6da69 by Thomas Guillem at 2022-03-05T02:10:49+00:00
smb2: make the netbios resolver interruptible

- - - - -


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 @@
-59963c1d12839004c7e3717cf5f029ffc5f10d72b133d88c33c1367f4343befb170c2b10f7cbc690d1700b380e298436e34b80fc214546f6ded104c649ee21eb  libdsm-0.3.2.tar.gz
+34542dbe8cfd52b0ef94ccee697b50cce359cae1c58e14289667285519a6a6579323bbfbb29297cdd2dd4ccd2b7da7c571eba3fb18d596f064a3233029efb484  libdsm-0.4.0.tar.xz


=====================================
contrib/src/libdsm/rules.mak
=====================================
@@ -1,14 +1,13 @@
 # libdsm
 
-#LIBDSM_GITURL := git://github.com/videolabs/libdsm.git
-LIBDSM_VERSION := 0.3.2
-LIBDSM_URL := https://github.com/videolabs/libdsm/releases/download/v$(LIBDSM_VERSION)/libdsm-$(LIBDSM_VERSION).tar.gz
+LIBDSM_VERSION := 0.4.0
+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"),)
 PKGS_FOUND += libdsm
 endif
 
-$(TARBALLS)/libdsm-$(LIBDSM_VERSION).tar.gz:
+$(TARBALLS)/libdsm-$(LIBDSM_VERSION).tar.xz:
 	$(call download_pkg,$(LIBDSM_URL),libdsm)
 
 LIBDSM_CONF = $(HOSTCONF)
@@ -16,9 +15,9 @@ LIBDSM_CONF = $(HOSTCONF)
 ifndef WITH_OPTIMIZATION
 LIBDSM_CONF += --enable-debug
 endif
-.sum-libdsm: libdsm-$(LIBDSM_VERSION).tar.gz
+.sum-libdsm: libdsm-$(LIBDSM_VERSION).tar.xz
 
-libdsm: libdsm-$(LIBDSM_VERSION).tar.gz .sum-libdsm
+libdsm: libdsm-$(LIBDSM_VERSION).tar.xz .sum-libdsm
 	$(UNPACK)
 	$(MOVE)
 
@@ -27,11 +26,8 @@ ifdef HAVE_WIN32
 DEPS_libdsm += pthreads $(DEPS_pthreads)
 endif
 
-.libdsm: libdsm
-	cd $< && touch "config.rpath"
-	$(RECONF)
-	cd $< && $(HOSTVARS_PIC) ./configure --disable-programs $(LIBDSM_CONF)
-	cd $< && $(MAKE)
-	$(call pkg_static,"libdsm.pc")
-	cd $< && $(MAKE) install
+.libdsm: libdsm crossfile.meson
+	cd $< && rm -rf ./build
+	cd $< && $(HOSTVARS_MESON) $(MESON) -Dauto_features=disabled -Dbinaries=false build
+	cd $< && cd build && ninja install
 	touch $@


=====================================
modules/access/dsm/access.c
=====================================
@@ -130,7 +130,6 @@ static int add_item( stream_t *p_access,  struct vlc_readdir_helper *p_rdh,
 
 typedef struct
 {
-    netbios_ns         *p_ns;               /**< Netbios name service */
     smb_session        *p_session;          /**< bdsm SMB Session object */
 
     vlc_url_t           url;
@@ -147,6 +146,53 @@ typedef struct
     struct vlc_access_cache_entry *cache_entry;
 } access_sys_t;
 
+#if BDSM_VERSION_CURRENT >= 5
+
+static void
+smb_session_interrupt_callback( void *data )
+{
+    smb_session_abort( data );
+}
+
+static inline void
+smb_session_interrupt_register( access_sys_t *sys )
+{
+    vlc_interrupt_register( smb_session_interrupt_callback, sys->p_session );
+}
+
+static inline void
+smb_session_interrupt_unregister( void )
+{
+    vlc_interrupt_unregister();
+}
+
+static void
+netbios_ns_interrupt_callback( void *data )
+{
+    netbios_ns_abort( data );
+}
+
+static inline void
+netbios_ns_interrupt_register( netbios_ns *ns )
+{
+    vlc_interrupt_register( netbios_ns_interrupt_callback, ns );
+}
+
+static inline void
+netbios_ns_interrupt_unregister( void )
+{
+    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)
+
+#endif
+
 /*****************************************************************************
  * Open: Initialize module's data structures and libdsm
  *****************************************************************************/
@@ -162,10 +208,6 @@ static int Open( vlc_object_t *p_this )
     if( p_access->p_sys == NULL )
         return VLC_ENOMEM;
 
-    p_sys->p_ns = netbios_ns_new();
-    if( p_sys->p_ns == NULL )
-        goto error;
-
     p_sys->p_session = smb_session_new();
     if( p_sys->p_session == NULL )
         goto error;
@@ -184,16 +226,22 @@ static int Open( vlc_object_t *p_this )
 
     get_path( p_access );
 
+    smb_session_interrupt_register( p_sys );
+
     if( login( p_access ) != VLC_SUCCESS )
     {
         msg_Err( p_access, "Unable to open file with path %s (in share %s)",
                  p_sys->psz_path, p_sys->psz_share );
+        smb_session_interrupt_unregister();
         goto error;
     }
 
     /* If there is no shares, browse them */
     if( !p_sys->psz_share )
+    {
+        smb_session_interrupt_unregister();
         return BrowserInit( p_access );
+    }
 
     assert(p_sys->i_fd > 0);
 
@@ -204,9 +252,12 @@ 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();
         return BrowserInit( p_access );
     }
 
+    smb_session_interrupt_unregister();
+
     msg_Dbg( p_access, "Successfully opened smb://%s", p_access->psz_location );
 
     ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek );
@@ -250,8 +301,6 @@ static void Close( vlc_object_t *p_this )
     stream_t     *p_access = (stream_t*)p_this;
     access_sys_t *p_sys = p_access->p_sys;
 
-    if( p_sys->p_ns )
-        netbios_ns_destroy( p_sys->p_ns );
     if( p_sys->i_fd )
         smb_fclose( p_sys->p_session, p_sys->i_fd );
     vlc_UrlClean( &p_sys->url );
@@ -278,11 +327,20 @@ static int get_address( stream_t *p_access )
         /* This is not an ip address, let's try netbios/dns resolve */
         struct addrinfo *p_info = NULL;
 
+        netbios_ns *p_ns = netbios_ns_new();
+        if( p_ns == NULL )
+            return VLC_EGENERIC;
+        netbios_ns_interrupt_register( p_ns );
+
         /* Is this a netbios name on this LAN ? */
         uint32_t ip4_addr;
-        if( netbios_ns_resolve( p_sys->p_ns, p_sys->url.psz_host,
-                                NETBIOS_FILESERVER,
-                                &ip4_addr) == 0 )
+
+        int ret = netbios_ns_resolve( p_ns, p_sys->url.psz_host,
+                                      NETBIOS_FILESERVER, &ip4_addr);
+        netbios_ns_interrupt_unregister();
+        netbios_ns_destroy( p_ns );
+
+        if( ret == 0 )
         {
             p_sys->addr.s_addr = ip4_addr;
             strlcpy( p_sys->netbios_name, p_sys->url.psz_host, 16);
@@ -307,8 +365,17 @@ static int get_address( stream_t *p_access )
             return VLC_EGENERIC;
     }
 
+    netbios_ns *p_ns = netbios_ns_new();
+    if( p_ns == NULL )
+        return VLC_EGENERIC;
+    netbios_ns_interrupt_register( p_ns );
+
     /* We have an IP address, let's find the NETBIOS name */
-    const char *psz_nbt = netbios_ns_inverse( p_sys->p_ns, p_sys->addr.s_addr );
+    const char *psz_nbt = netbios_ns_inverse( p_ns, p_sys->addr.s_addr );
+
+    netbios_ns_interrupt_unregister();
+    netbios_ns_destroy( p_ns );
+
     if( psz_nbt != NULL )
         strlcpy( p_sys->netbios_name, psz_nbt, 16 );
     else
@@ -573,7 +640,11 @@ static int Seek( stream_t *p_access, uint64_t i_pos )
 
     msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
 
-    if (smb_fseek(p_sys->p_session, p_sys->i_fd, i_pos, SMB_SEEK_SET) == -1)
+    smb_session_interrupt_register( p_sys );
+    int ret = smb_fseek(p_sys->p_session, p_sys->i_fd, i_pos, SMB_SEEK_SET);
+    smb_session_interrupt_unregister();
+
+    if (ret == -1)
         return VLC_EGENERIC;
 
     return VLC_SUCCESS;
@@ -587,7 +658,10 @@ static ssize_t Read( stream_t *p_access, void *p_buffer, size_t i_len )
     access_sys_t *p_sys = p_access->p_sys;
     int i_read;
 
+    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( i_read < 0 )
     {
         msg_Err( p_access, "read failed" );
@@ -678,9 +752,16 @@ static int BrowseShare( stream_t *p_access, input_item_node_t *p_node )
     size_t          share_count;
     int             i_ret = VLC_SUCCESS;
 
+    smb_session_interrupt_register( p_sys );
+
     if( smb_share_get_list( p_sys->p_session, &shares, &share_count )
         != DSM_SUCCESS )
+    {
+        smb_session_interrupt_unregister();
         return VLC_EGENERIC;
+    }
+
+    smb_session_interrupt_unregister();
 
     struct vlc_readdir_helper rdh;
     vlc_readdir_helper_init( &rdh, p_access, p_node );
@@ -715,11 +796,18 @@ static int BrowseDirectory( stream_t *p_access, input_item_node_t *p_node )
     {
         if( asprintf( &psz_query, "%s\\*", p_sys->psz_path ) == -1 )
             return VLC_ENOMEM;
+
+        smb_session_interrupt_register( p_sys );
         files = smb_find( p_sys->p_session, p_sys->i_tid, psz_query );
+        smb_session_interrupt_unregister();
         free( psz_query );
     }
     else
+    {
+        smb_session_interrupt_register( p_sys );
         files = smb_find( p_sys->p_session, p_sys->i_tid, "\\*" );
+        smb_session_interrupt_unregister();
+    }
 
     if( files == NULL )
         return VLC_EGENERIC;


=====================================
modules/access/smb2.c
=====================================
@@ -49,8 +49,34 @@
 #include <smb2/libsmb2-raw.h>
 
 #ifdef HAVE_DSM
-# include <bdsm/netbios_ns.h>
-# include <bdsm/netbios_defs.h>
+# include <bdsm/bdsm.h>
+
+#if BDSM_VERSION_CURRENT >= 5
+
+static void
+netbios_ns_interrupt_callback(void *data)
+{
+    netbios_ns_abort(data);
+}
+
+static inline void
+netbios_ns_interrupt_register(netbios_ns *ns)
+{
+    vlc_interrupt_register(netbios_ns_interrupt_callback, ns);
+}
+
+static inline void
+netbios_ns_interrupt_unregister(void)
+{
+    vlc_interrupt_unregister();
+}
+
+#else
+
+#define netbios_ns_interrupt_register( ns ) do {} while (0)
+#define netbios_ns_interrupt_unregister() do {} while (0)
+#endif
+
 #endif
 
 #ifdef HAVE_ARPA_INET_H
@@ -772,6 +798,7 @@ vlc_smb2_resolve(stream_t *access, const char *host, unsigned port)
     netbios_ns *ns = netbios_ns_new();
     if (!ns)
         return NULL;
+    netbios_ns_interrupt_register(ns);
     uint32_t ip4_addr;
     if (netbios_ns_resolve(ns, host, NETBIOS_FILESERVER, &ip4_addr) == 0)
     {
@@ -779,6 +806,7 @@ vlc_smb2_resolve(stream_t *access, const char *host, unsigned port)
         if (inet_ntop(AF_INET, &ip4_addr, ip, sizeof(ip)))
             out_host = strdup(ip);
     }
+    netbios_ns_interrupt_unregister();
     netbios_ns_destroy(ns);
     return out_host;
 #else



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a37aa1c8645df9ff81e502b230c6acd72bd6f75d...f0c6da69cc02051112d2fc60f30a886b1f2aecc4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a37aa1c8645df9ff81e502b230c6acd72bd6f75d...f0c6da69cc02051112d2fc60f30a886b1f2aecc4
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