Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 755c506d rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MOD: Don't be greedy on the db and harddrive while importing favorites

When importing favorites, the db lock will be always taken by the repo
module, this is bad for lektord because the main thread will no longer
be able to lock and use the db. It will also use constantly the hard
drive.

An easy and dirty fix is to sleep a bit...
parent 3827da65
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!141Improve MPD compatibility
......@@ -102,6 +102,17 @@ struct __file {
* Private functions *
*********************/
/* Sleep a bit, to not overuse ressources */
static inline void
__sleep(void)
{
struct timespec time_sleep = {
.tv_sec = 0,
.tv_nsec = 100000000L,
}; /* Sleep for 0.1s */
nanosleep(&time_sleep, NULL); /* Sleep a bit, better for Hard drive */
}
/* Recursive mkdir, where the last word of the string is a file, not a folder. */
static inline void
__mkdir(const char *dir, unsigned int umask)
......@@ -393,11 +404,7 @@ __handle_got_json_internal_callback(const char *key, const char *val, int comp,
/* The `void *user` is complete */
else if (comp) {
struct timespec time_sleep = {
.tv_sec = 0,
.tv_nsec = 100000000L,
}; /* Sleep for 0.1s */
nanosleep(&time_sleep, NULL); /* Sleep a bit, better for Hard drive */
__sleep();
long filestamp = 0;
int current_id = 0;
......@@ -559,6 +566,8 @@ __handle_fav_list_internal(const char UNUSED *key, const char *val, int UNUSED c
LOG_ERROR("REPO", "Failed to add kara %ld to playlist %s", uri->uri.id, uri->fav);
return;
}
/* Dirty fix for db lock and hard drive usage */
__sleep();
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter