Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
6c122576
Commit
6c122576
authored
Aug 23, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gnutls: drop useless global mutex and init if version >= 3.3.0
parent
65ef0b68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
29 deletions
+39
-29
modules/misc/gnutls.c
modules/misc/gnutls.c
+39
-29
No files found.
modules/misc/gnutls.c
View file @
6c122576
...
...
@@ -36,52 +36,64 @@
#include <gnutls/x509.h>
#include "dhparams.h"
#if (GNUTLS_VERSION_NUMBER >= 0x030300)
static
int
gnutls_Init
(
vlc_object_t
*
obj
)
{
const
char
*
version
=
gnutls_check_version
(
"3.3.0"
);
if
(
version
==
NULL
)
{
msg_Err
(
obj
,
"unsupported GnuTLS version"
);
return
-
1
;
}
msg_Dbg
(
p_this
,
"using GnuTLS verson %s"
,
version
);
return
0
;
}
# define gnutls_Deinit() (void)0
#else
static
vlc_mutex_t
gnutls_mutex
=
VLC_STATIC_MUTEX
;
/**
* Initializes GnuTLS with proper locking.
* @return VLC_SUCCESS on success, a VLC error code otherwise.
*/
static
int
gnutls_Init
(
vlc_object_t
*
p_this
)
static
int
gnutls_Init
(
vlc_object_t
*
obj
)
{
int
ret
=
VLC_EGENERIC
;
vlc_mutex_lock
(
&
gnutls_mutex
);
if
(
gnutls_global_init
())
const
char
*
version
=
gnutls_check_version
(
"3.1.9"
);
if
(
version
==
NULL
)
{
msg_Err
(
p_this
,
"cannot initialize GnuTLS
"
);
goto
error
;
msg_Err
(
obj
,
"unsupported GnuTLS version
"
);
return
-
1
;
}
msg_Dbg
(
obj
,
"using GnuTLS verson %s"
,
version
);
const
char
*
psz_version
=
gnutls_check_version
(
"3.1.9"
);
if
(
psz_version
==
NULL
)
if
(
gnutls_check_version
(
"3.3.0"
)
==
NULL
)
{
msg_Err
(
p_this
,
"unsupported GnuTLS version"
);
gnutls_global_deinit
();
goto
error
;
}
int
val
;
msg_Dbg
(
p_this
,
"GnuTLS v%s initialized"
,
psz_version
);
ret
=
VLC_SUCCESS
;
vlc_mutex_lock
(
&
gnutls_mutex
);
val
=
gnutls_global_init
();
vlc_mutex_unlock
(
&
gnutls_mutex
);
error:
vlc_mutex_unlock
(
&
gnutls_mutex
);
return
ret
;
if
(
val
)
{
msg_Err
(
obj
,
"cannot initialize GnuTLS"
);
return
-
1
;
}
}
return
0
;
}
/**
* Deinitializes GnuTLS.
*/
static
void
gnutls_Deinit
(
v
lc_object_t
*
p_this
)
static
void
gnutls_Deinit
(
v
oid
)
{
vlc_mutex_lock
(
&
gnutls_mutex
);
gnutls_global_deinit
();
msg_Dbg
(
p_this
,
"GnuTLS deinitialized"
);
vlc_mutex_unlock
(
&
gnutls_mutex
);
}
#endif
static
int
gnutls_Error
(
vlc_object_t
*
obj
,
int
val
)
{
...
...
@@ -412,7 +424,7 @@ static int OpenClient (vlc_tls_creds_t *crd)
{
msg_Err
(
crd
,
"cannot allocate credentials: %s"
,
gnutls_strerror
(
val
));
gnutls_Deinit
(
VLC_OBJECT
(
crd
)
);
gnutls_Deinit
();
return
VLC_EGENERIC
;
}
...
...
@@ -439,8 +451,7 @@ static void CloseClient (vlc_tls_creds_t *crd)
gnutls_certificate_credentials_t
x509
=
crd
->
sys
;
gnutls_certificate_free_credentials
(
x509
);
gnutls_Deinit
(
VLC_OBJECT
(
crd
));
gnutls_Deinit
();
}
#ifdef ENABLE_SOUT
...
...
@@ -567,7 +578,7 @@ static int OpenServer (vlc_tls_creds_t *crd, const char *cert, const char *key)
error:
free
(
sys
);
gnutls_Deinit
(
VLC_OBJECT
(
crd
)
);
gnutls_Deinit
();
return
VLC_EGENERIC
;
}
...
...
@@ -582,8 +593,7 @@ static void CloseServer (vlc_tls_creds_t *crd)
gnutls_certificate_free_credentials
(
sys
->
x509_cred
);
gnutls_dh_params_deinit
(
sys
->
dh_params
);
free
(
sys
);
gnutls_Deinit
(
VLC_OBJECT
(
crd
));
gnutls_Deinit
();
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment