Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
444
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
c6d72dff
Commit
c6d72dff
authored
2 years ago
by
Steve Lhomme
Committed by
Jean-Baptiste Kempf
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
access: cache: disable code not used without VLC_ACCESS_CACHE_CAN_REGISTER
parent
225e0c1e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1721
access: cache: disable code not used without VLC_ACCESS_CACHE_CAN_REGISTER
Pipeline
#208891
passed with stage
in 43 minutes and 19 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/access/cache.c
+12
-2
12 additions, 2 deletions
modules/access/cache.c
modules/access/cache.h
+19
-10
19 additions, 10 deletions
modules/access/cache.h
with
31 additions
and
12 deletions
modules/access/cache.c
+
12
−
2
View file @
c6d72dff
...
...
@@ -64,6 +64,7 @@ vlc_access_cache_entry_New(void *context, const char *url, const char *username,
return
entry
;
}
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
static
void
*
vlc_access_cache_Thread
(
void
*
data
)
{
...
...
@@ -104,7 +105,6 @@ vlc_access_cache_InitOnce(void *data)
{
struct
vlc_access_cache
*
cache
=
data
;
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_mutex_lock
(
&
cache
->
lock
);
cache
->
running
=
true
;
...
...
@@ -114,7 +114,6 @@ vlc_access_cache_InitOnce(void *data)
cache
->
running
=
false
;
vlc_mutex_unlock
(
&
cache
->
lock
);
#endif
}
void
...
...
@@ -138,15 +137,19 @@ vlc_access_cache_Destroy(struct vlc_access_cache *cache)
vlc_access_cache_entry_Delete
(
entry
);
}
}
#endif
void
vlc_access_cache_AddEntry
(
struct
vlc_access_cache
*
cache
,
struct
vlc_access_cache_entry
*
entry
)
{
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_once
(
&
cache
->
once
,
vlc_access_cache_InitOnce
,
cache
);
#endif
vlc_mutex_lock
(
&
cache
->
lock
);
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
if
(
!
cache
->
running
)
{
vlc_mutex_unlock
(
&
cache
->
lock
);
...
...
@@ -154,6 +157,7 @@ vlc_access_cache_AddEntry(struct vlc_access_cache *cache,
vlc_access_cache_entry_Delete
(
entry
);
return
;
}
#endif
struct
vlc_access_cache_entry
*
it
;
size_t
count
=
0
;
...
...
@@ -171,7 +175,9 @@ vlc_access_cache_AddEntry(struct vlc_access_cache *cache,
entry
->
timeout
=
vlc_tick_now
()
+
VLC_ACCESS_CACHE_TTL
;
vlc_list_append
(
&
entry
->
node
,
&
cache
->
entries
);
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_cond_signal
(
&
cache
->
cond
);
#endif
vlc_mutex_unlock
(
&
cache
->
lock
);
}
...
...
@@ -179,7 +185,9 @@ struct vlc_access_cache_entry *
vlc_access_cache_GetEntry
(
struct
vlc_access_cache
*
cache
,
const
char
*
url
,
const
char
*
username
)
{
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_once
(
&
cache
->
once
,
vlc_access_cache_InitOnce
,
cache
);
#endif
vlc_mutex_lock
(
&
cache
->
lock
);
...
...
@@ -193,7 +201,9 @@ vlc_access_cache_GetEntry(struct vlc_access_cache *cache,
&&
(
username
!=
NULL
?
strcmp
(
username
,
it
->
username
)
==
0
:
true
))
{
vlc_list_remove
(
&
it
->
node
);
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_cond_signal
(
&
cache
->
cond
);
#endif
vlc_mutex_unlock
(
&
cache
->
lock
);
return
it
;
}
...
...
This diff is collapsed.
Click to expand it.
modules/access/cache.h
+
19
−
10
View file @
c6d72dff
...
...
@@ -38,17 +38,26 @@ struct vlc_access_cache_entry
struct
vlc_list
node
;
};
#ifdef __has_attribute
#if __has_attribute(destructor)
#define VLC_ACCESS_CACHE_CAN_REGISTER
#endif
#endif
struct
vlc_access_cache
{
vlc_once_t
once
;
vlc_mutex_t
lock
;
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
vlc_once_t
once
;
vlc_cond_t
cond
;
vlc_thread_t
thread
;
bool
running
;
#endif
struct
vlc_list
entries
;
};
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
#define VLC_ACCESS_CACHE_INITIALIZER(name) { \
.once = VLC_STATIC_ONCE, \
.lock = VLC_STATIC_MUTEX, \
...
...
@@ -56,6 +65,12 @@ struct vlc_access_cache
.running = false, \
.entries = VLC_LIST_INITIALIZER(&name.entries), \
}
#else
#define VLC_ACCESS_CACHE_INITIALIZER(name) { \
.lock = VLC_STATIC_MUTEX, \
.entries = VLC_LIST_INITIALIZER(&name.entries), \
}
#endif
static
inline
char
*
vlc_access_cache_entry_CreateSmbUrl
(
const
char
*
server
,
const
char
*
share
)
...
...
@@ -89,9 +104,6 @@ vlc_access_cache_entry_NewSmb(void *context, const char *server,
void
vlc_access_cache_entry_Delete
(
struct
vlc_access_cache_entry
*
entry
);
void
vlc_access_cache_Destroy
(
struct
vlc_access_cache
*
cache
);
void
vlc_access_cache_AddEntry
(
struct
vlc_access_cache
*
cache
,
struct
vlc_access_cache_entry
*
entry
);
...
...
@@ -116,13 +128,10 @@ vlc_access_cache_GetSmbEntry(struct vlc_access_cache *cache,
return
entry
;
}
#ifdef __has_attribute
#if __has_attribute(destructor)
#define VLC_ACCESS_CACHE_CAN_REGISTER
#endif
#endif
#ifdef VLC_ACCESS_CACHE_CAN_REGISTER
void
vlc_access_cache_Destroy
(
struct
vlc_access_cache
*
cache
);
#define VLC_ACCESS_CACHE_REGISTER(name) \
static struct vlc_access_cache name = VLC_ACCESS_CACHE_INITIALIZER(name); \
__attribute__((destructor)) static void vlc_access_cache_destructor_##name(void) \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment