mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-25 12:06:12 -05:00
[spotify] Thread safety for the webapi access
The web api might be accessed from different threads (library, worker, dacp), therefor protect from concurrently running refresh-token requests (accessing the globals in spotify_webapi.c)
This commit is contained in:
@@ -1967,9 +1967,10 @@ spotify_init(void)
|
||||
|
||||
CHECK_ERR(L_SPOTIFY, mutex_init(&login_lck));
|
||||
CHECK_ERR(L_SPOTIFY, pthread_cond_init(&login_cond, NULL));
|
||||
|
||||
CHECK_ERR(L_SPOTIFY, mutex_init(&status_lck));
|
||||
|
||||
spotifywebapi_init();
|
||||
|
||||
/* Spawn thread */
|
||||
ret = pthread_create(&tid_spotify, NULL, spotify, NULL);
|
||||
if (ret < 0)
|
||||
@@ -1988,6 +1989,8 @@ spotify_init(void)
|
||||
return 0;
|
||||
|
||||
thread_fail:
|
||||
spotifywebapi_deinit();
|
||||
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_destroy(&status_lck));
|
||||
CHECK_ERR(L_SPOTIFY, pthread_cond_destroy(&login_cond));
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_destroy(&login_lck));
|
||||
@@ -2054,6 +2057,9 @@ spotify_deinit(void)
|
||||
CHECK_ERR(L_SPOTIFY, pthread_cond_destroy(&login_cond));
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_destroy(&login_lck));
|
||||
|
||||
/* Deinit web api */
|
||||
spotifywebapi_deinit();
|
||||
|
||||
/* Free audio buffer */
|
||||
evbuffer_free(spotify_audio_buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user