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

Everything compiles

parent ec70295f
Branches
Étiquettes
1 requête de fusion!65Resolve "Sync from kurisu"
...@@ -48,7 +48,7 @@ typedef struct mthread_sem_s mthread_sem_t; ...@@ -48,7 +48,7 @@ typedef struct mthread_sem_s mthread_sem_t;
/* Function for handling threads. */ /* Function for handling threads. */
int mthread_create(mthread_t *__threadp, const mthread_attr_t *__attr, void *(*__start_routine) (void *), void *__arg); int mthread_create(mthread_t *__threadp, const mthread_attr_t __attr, void *(*__start_routine) (void *), void *__arg);
mthread_t mthread_self(void); mthread_t mthread_self(void);
int mthread_equal (mthread_t __thread1, mthread_t __thread2); int mthread_equal (mthread_t __thread1, mthread_t __thread2);
......
...@@ -290,7 +290,7 @@ mthread_init(void) ...@@ -290,7 +290,7 @@ mthread_init(void)
if ATTR is NULL), and call function START_ROUTINE with given if ATTR is NULL), and call function START_ROUTINE with given
arguments ARG. */ arguments ARG. */
int int
mthread_create(mthread_t *__threadp, const mthread_attr_t *__attr, void *(*__start_routine) (void *), void *__arg) mthread_create(mthread_t *__threadp, const mthread_attr_t __attr, void *(*__start_routine) (void *), void *__arg)
{ {
if (is_mthread_init == 0) { if (is_mthread_init == 0) {
__mthread_lib_init(0); __mthread_lib_init(0);
...@@ -309,9 +309,9 @@ mthread_create(mthread_t *__threadp, const mthread_attr_t *__attr, void *(*__sta ...@@ -309,9 +309,9 @@ mthread_create(mthread_t *__threadp, const mthread_attr_t *__attr, void *(*__sta
mthread_init_thread(mctx); mthread_init_thread(mctx);
if (__attr) { if (__attr) {
if (*__attr & ATTR_DETACHED) if (__attr & ATTR_DETACHED)
mctx->detached = DETACHED; mctx->detached = DETACHED;
if (*__attr & ATTR_DETACHED_FREE) if (__attr & ATTR_DETACHED_FREE)
mctx->detached = DETACHED_FREE; mctx->detached = DETACHED_FREE;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <mthread/mthread.h> #include <mthread/mthread.h>
#include <lektor/macro.h> #include <lektor/macro.h>
#include <lektor/repo.h> #include <lektor/repo.h>
#include <lektor/thread.h> #include <lektor/database.h>
/* Find it in the repo/curl.c file. FIXME */ /* Find it in the repo/curl.c file. FIXME */
extern int extern int
...@@ -49,7 +49,13 @@ repo_download_id_async(struct lkt_repo *const repo, const size_t id) ...@@ -49,7 +49,13 @@ repo_download_id_async(struct lkt_repo *const repo, const size_t id)
kara->id = id; kara->id = id;
/* Thread */ /* Thread */
return mthread_create(th, NULL, __repo_download_id_async, arg); mthread_t *th = calloc(1, sizeof(mthread_t));
if (!th) {
free(arg);
LOG_ERROR_SCT("REPO", "%s", "Out of memory");
return 1;
}
return mthread_create(th, ATTR_DETACHED_FREE, __repo_download_id_async, arg);
} }
/* Get all the kara, make them unavailable */ /* Get all the kara, make them unavailable */
...@@ -96,7 +102,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec ...@@ -96,7 +102,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
if (safe_json_get_int32(kara_json, "song_number", &kara->mdt.song_number)) if (safe_json_get_int32(kara_json, "song_number", &kara->mdt.song_number))
goto err; goto err;
if (database_update_add(db, kara->filename, &kara->mdt, kara->id, false)) if (database_update_add((sqlite3 *) db, kara->filename, &kara->mdt, kara->id, false))
LOG_ERROR_SCT("REPO", "Could not add unavailable kara %ld to db", kara->id); LOG_ERROR_SCT("REPO", "Could not add unavailable kara %ld to db", kara->id);
goto err; goto err;
} }
...@@ -119,5 +125,10 @@ __repo_get_all_id_async(void *arg) ...@@ -119,5 +125,10 @@ __repo_get_all_id_async(void *arg)
inline int inline int
repo_get_allid_async(struct lkt_repo *const repo) repo_get_allid_async(struct lkt_repo *const repo)
{ {
return mthread_create(th, NULL, __repo_get_all_id_async, repo); mthread_t *th = calloc(1, sizeof(mthread_t));
if (!th) {
LOG_ERROR_SCT("REPO", "%s", "Out of memory");
return 1;
}
return mthread_create(th, ATTR_DETACHED_FREE, __repo_get_all_id_async, repo);
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter