diff --git a/examples/client/main.c b/examples/client/main.c index 5c9c397..6d782ea 100644 --- a/examples/client/main.c +++ b/examples/client/main.c @@ -21,17 +21,14 @@ int main(int argc, char *argv[]) { goto end; } - if (!lm_ctx_pools_add(&ctx, "test", argv[1])) { + if (lm_ctx_pools_add(&ctx, "test", argv[1]) == NULL) { printf("failed to add pool: %s (%d)\n", lm_strerror(), lm_error()); goto end; } - lm_ctx_pools_test(&ctx); - - if (!lm_ctx_pools_load(&ctx, true, NULL, NULL)) { - printf("failed to load pools: %s (%d)\n", lm_strerror(), lm_error()); - goto end; - } + lm_ctx_pools_test(&ctx, NULL, NULL); + lm_ctx_pools_get_info(&ctx, true, NULL, NULL); + lm_ctx_pools_get_list(&ctx, true, NULL, NULL); ret = EXIT_SUCCESS; diff --git a/examples/tests/.gitignore b/examples/pools/test/.gitignore similarity index 100% rename from examples/tests/.gitignore rename to examples/pools/test/.gitignore diff --git a/examples/tests/INFO b/examples/pools/test/INFO similarity index 100% rename from examples/tests/INFO rename to examples/pools/test/INFO diff --git a/examples/tests/LIST b/examples/pools/test/LIST similarity index 100% rename from examples/tests/LIST rename to examples/pools/test/LIST diff --git a/examples/tests/grep_3.11.mpf b/examples/pools/test/grep_3.11.mpf similarity index 100% rename from examples/tests/grep_3.11.mpf rename to examples/pools/test/grep_3.11.mpf diff --git a/examples/tests/grep_3.11.mpf.sig b/examples/pools/test/grep_3.11.mpf.sig similarity index 100% rename from examples/tests/grep_3.11.mpf.sig rename to examples/pools/test/grep_3.11.mpf.sig diff --git a/examples/tests/which_2.21.mpf b/examples/pools/test/which_2.21.mpf similarity index 100% rename from examples/tests/which_2.21.mpf rename to examples/pools/test/which_2.21.mpf diff --git a/examples/tests/which_2.21.mpf.sig b/examples/pools/test/which_2.21.mpf.sig similarity index 100% rename from examples/tests/which_2.21.mpf.sig rename to examples/pools/test/which_2.21.mpf.sig diff --git a/examples/server/main.c b/examples/server/main.c index 74f3577..43a8d61 100644 --- a/examples/server/main.c +++ b/examples/server/main.c @@ -3,6 +3,8 @@ #include #include +#define DATA_DIR "./examples" + int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; @@ -11,25 +13,19 @@ int main(int argc, char *argv[]) { return ret; } - lm_ctx_t ctx; - lm_pool_t *pool; + lm_ctx_t ctx; lm_ctx_init(&ctx); - if ((pool = lm_ctx_pools_add(&ctx, "test", "mptp://127.0.0.1:5858")) == NULL) { + if (!lm_ctx_set_data(&ctx, DATA_DIR)) { + printf("failed to set data dir: %s (%d)\n", lm_strerror(), lm_error()); + goto end; + } + + if (lm_ctx_pools_add(&ctx, "test", "mptp://127.0.0.1:5858") == NULL) { printf("failed to add pool: %s (%d)\n", lm_strerror(), lm_error()); goto end; } - if (!lm_pool_info_load(pool, "./examples/tests/INFO")) { - printf("failed to load pool info: %s (%d)\n", lm_strerror(), lm_error()); - goto end; - } - - if (!lm_pool_list_load(pool, "./examples/tests/LIST")) { - printf("failed to load pool list: %s (%d)\n", lm_strerror(), lm_error()); - goto end; - } - if (!lm_ctx_pools_serve(&ctx, argv[1], 10)) { printf("failed to serve the pools: %s (%d)\n", lm_strerror(), lm_error()); goto end; diff --git a/include/ctx.h b/include/ctx.h index 715efe9..d163a58 100644 --- a/include/ctx.h +++ b/include/ctx.h @@ -13,6 +13,7 @@ void lm_ctx_free(lm_ctx_t *ctx); lm_pool_t *lm_ctx_pools_add(lm_ctx_t *ctx, char *name, char *url); bool lm_ctx_pools_del(lm_ctx_t *ctx, char *name); void lm_ctx_pools_clear(lm_ctx_t *ctx); -void lm_ctx_pools_test(lm_ctx_t *ctx); bool lm_ctx_pools_serve(lm_ctx_t *ctx, char *addr, uint8_t threads); -bool lm_ctx_pools_load(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data); +void lm_ctx_pools_test(lm_ctx_t *ctx, lm_ctx_pools_callback_t callback, void *data); +void lm_ctx_pools_get_info(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data); +void lm_ctx_pools_get_list(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data); diff --git a/include/error.h b/include/error.h index 338625b..e41f1e1 100644 --- a/include/error.h +++ b/include/error.h @@ -58,6 +58,7 @@ typedef enum lm_error { LM_ERR_CtxDataNoWrite = 53, LM_ERR_CtxDataFailMkdir = 54, LM_ERR_ArcRealpathFail = 55, + LM_ERR_PoolTestNotPong = 56, } lm_error_t; typedef struct lm_error_desc { diff --git a/include/pool.h b/include/pool.h index e4b93be..0fe67c7 100644 --- a/include/pool.h +++ b/include/pool.h @@ -23,14 +23,15 @@ bool lm_pool_add(lm_pool_t *pool, lm_pkg_t *pkg); void lm_pool_paths_set_info(lm_pool_t *pool, char *info_path); void lm_pool_paths_set_list(lm_pool_t *pool, char *list_path); +bool lm_pool_paths_is_empty(lm_pool_t *pool); void lm_pool_paths_free(lm_pool_t *pool); -bool lm_pool_info_load(lm_pool_t *pool, char *file); -bool lm_pool_info_get(lm_pool_t *pool, char *file); +bool lm_pool_info_load(lm_pool_t *pool); +bool lm_pool_info_get(lm_pool_t *pool); void lm_pool_info_free(lm_pool_t *pool); -bool lm_pool_list_load(lm_pool_t *pool, char *file); -bool lm_pool_list_get(lm_pool_t *pool, char *file); +bool lm_pool_list_load(lm_pool_t *pool); +bool lm_pool_list_get(lm_pool_t *pool); void lm_pool_serve(lm_pool_t *pool, lm_mptp_t *packet, int sock, struct sockaddr *addr); void lm_pool_serve_thread(void *arg); diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index 3972e7f..2c99857 100644 --- a/locale/tr/LC_MESSAGES/libmp.po +++ b/locale/tr/LC_MESSAGES/libmp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-28 21:45+0300\n" +"POT-Creation-Date: 2024-06-28 23:08+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -251,3 +251,7 @@ msgstr "" #: src/error.c:69 msgid "failed to create specified data directory" msgstr "" + +#: src/error.c:70 +msgid "pool did not respond ping with pong" +msgstr "" diff --git a/src/ctx/ctx.c b/src/ctx/ctx.c index fddb67f..906b8fb 100644 --- a/src/ctx/ctx.c +++ b/src/ctx/ctx.c @@ -2,15 +2,11 @@ #include "../../include/util.h" #include "../../include/ctx.h" -#include -#include #include #include #include -#include #include #include -#include void lm_ctx_init(lm_ctx_t *ctx) { setlocale(LC_ALL, ""); @@ -66,14 +62,6 @@ bool lm_ctx_set_data(lm_ctx_t *ctx, char *dir){ return false; } - char poolsdir[strlen(dir)+10]; - snprintf(poolsdir, sizeof(poolsdir), "%s/pools", dir); - - if(!mkdir_ifnot(poolsdir)){ - lm_error_set(LM_ERR_CtxDataFailMkdir); - return false; - } - if(!is_dir(dir)){ lm_error_set(LM_ERR_CtxDataNotDir); return false; @@ -84,6 +72,14 @@ bool lm_ctx_set_data(lm_ctx_t *ctx, char *dir){ return false; } + char poolsdir[strlen(dir)+10]; + snprintf(poolsdir, sizeof(poolsdir), "%s/pools", dir); + + if(!mkdir_ifnot(poolsdir)){ + lm_error_set(LM_ERR_CtxDataFailMkdir); + return false; + } + ctx->data = strdup(dir); return true; } diff --git a/src/ctx/pools.c b/src/ctx/pools.c index 2cb1643..e64edee 100644 --- a/src/ctx/pools.c +++ b/src/ctx/pools.c @@ -4,14 +4,14 @@ #include "../../include/error.h" #include "../../include/thpool.h" -#include #include #include #include -#include -#include lm_pool_t *lm_ctx_pools_add(lm_ctx_t *ctx, char *name, char *url) { + if(NULL == name) + return NULL; + lm_pool_t *pool = lm_pool_new(name, url); if (NULL == pool) return false; @@ -19,6 +19,26 @@ lm_pool_t *lm_ctx_pools_add(lm_ctx_t *ctx, char *name, char *url) { pdebug(__func__, "pool name is %s", pool->name); pdebug(__func__, "pool URL is %s://%s:%d%s", pool->url.protocol, pool->url.host, pool->url.port, pool->url.path); + if(NULL != ctx->data){ + char poolp[strlen(ctx->data) + strlen(pool->name) + 20]; + snprintf(poolp, sizeof(poolp), "%s/pools/%s", ctx->data, pool->name); + size_t poolp_sz = strlen(poolp); + + if(!mkdir_ifnot(poolp)){ + lm_error_set(LM_ERR_CtxDataFailMkdir); + return false; + } + + char infop[poolp_sz + 10]; + sprintf(infop, "%s/INFO", poolp); + + char listp[poolp_sz + 10]; + sprintf(listp, "%s/LIST", poolp); + + lm_pool_paths_set_info(pool, infop); + lm_pool_paths_set_list(pool, listp); + } + if (NULL == ctx->pools) { ctx->pools = pool; return pool; @@ -48,22 +68,17 @@ void lm_ctx_pools_clear(lm_ctx_t *ctx) { ctx->pools = NULL; } -void lm_ctx_pools_test(lm_ctx_t *ctx) { +void lm_ctx_pools_test(lm_ctx_t *ctx, lm_ctx_pools_callback_t callback, void *data) { lm_pool_t *cur = ctx->pools; while (NULL != cur) { lm_pool_test(cur); - if (!cur->available) - pdebug(__func__, "%s is not avaliable: %s", cur->name, lm_strerror()); - cur = cur->next; - } -} -void lm_ctx_pools_get_info(lm_ctx_t *ctx) { - lm_pool_t *cur = ctx->pools; - while (NULL != cur) { - lm_pool_test(cur); if (!cur->available) pdebug(__func__, "%s is not avaliable: %s", cur->name, lm_strerror()); + + if(NULL != callback) + callback(ctx, cur, cur->available, data); + cur = cur->next; } } @@ -88,83 +103,70 @@ lm_pool_t *lm_ctx_pools_by_url(lm_ctx_t *ctx, char *host, char *path) { return NULL; } -bool lm_ctx_pool_load(lm_ctx_t *ctx, lm_pool_t *pool, bool force_update){ - if(NULL == ctx->data){ - printf("hello chat\n"); - lm_error_set(LM_ERR_CtxDataNULL); - return false; - } - - char poolp[strlen(ctx->data) + strlen(pool->name) + 20]; - snprintf(poolp, sizeof(poolp), "%s/pools/%s", ctx->data, pool->name); - size_t poolp_sz = strlen(poolp); - - if(!mkdir_ifnot(poolp)){ - lm_error_set(LM_ERR_CtxDataFailMkdir); - return false; - } - - char infop[poolp_sz + 10]; - sprintf(infop, "%s/INFO", poolp); - - char listp[poolp_sz + 10]; - sprintf(listp, "%s/LIST", poolp); - - if(force_update) - goto update; - - if(!lm_pool_info_load(pool, infop)){ - pdebug(__func__, "failed to load info for %s gonna try updating", pool->name); - goto update; - } - - if(!lm_pool_info_load(pool, listp)){ - pdebug(__func__, "failed to load list for %s gonna try updating", pool->name); - goto update; - } - -update: - unlink(infop); - unlink(listp); - - if(!pool->available){ - pdebug(__func__, "failed get info and list for %s, pool is not avaliable"); - return false; - } - - if(!lm_pool_info_get(pool, infop)){ - pdebug(__func__, "failed to get info for %s", pool->name); - return false; - } - - if(!lm_pool_list_get(pool, listp)){ - pdebug(__func__, "failed to get list for %s", pool->name); - return false; - } - - return true; -} - -bool lm_ctx_pools_load(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data){ - if(NULL == ctx){ - lm_error_set(LM_ERR_ArgNULL); - return false; - } - +void lm_ctx_pools_get_info(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data){ lm_pool_t *cur = ctx->pools; + bool status = false; + while(NULL != cur){ - bool status = lm_ctx_pool_load(ctx, cur, force_update); + if(lm_pool_paths_is_empty(cur)){ + pdebug(__func__, "(%s) failed to load info, pool paths are empty", cur->name); + goto next; + } - if(!status) - pdebug(__func__, "failed to load pool: %s", cur->name); + if(force_update) + goto update; + if(!lm_pool_info_load(cur)) + pdebug(__func__, "(%s) failed to load info, gonna try updating", cur->name); + + update: + if(!lm_pool_info_get(cur)){ + pdebug(__func__, "(%s) failed to update info", cur->name); + goto next; + } + + pdebug(__func__, "(%s) loaded pool info", cur->name); + status = true; + + next: if(NULL != callback) callback(ctx, cur, status, data); - + status = false; cur = cur->next; } +} - return true; +void lm_ctx_pools_get_list(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data){ + lm_pool_t *cur = ctx->pools; + bool status = false; + + while(NULL != cur){ + if(lm_pool_paths_is_empty(cur)){ + pdebug(__func__, "(%s) failed to load list, pool paths are empty", cur->name); + goto next; + } + + if(force_update) + goto update; + + if(!lm_pool_list_load(cur)) + pdebug(__func__, "(%s) failed to load list, gonna try updating", cur->name); + + update: + if(!lm_pool_list_get(cur)){ + pdebug(__func__, "(%s) failed to update list", cur->name); + goto next; + } + + pdebug(__func__, "(%s) loaded pool list", cur->name); + status = true; + + next: + if(NULL != callback) + callback(ctx, cur, status, data); + status = false; + cur = cur->next; + } } bool lm_ctx_pools_serve(lm_ctx_t *ctx, char *addr, uint8_t threads) { @@ -221,6 +223,13 @@ bool lm_ctx_pools_serve(lm_ctx_t *ctx, char *addr, uint8_t threads) { continue; } + if(lm_pool_paths_is_empty(pool)){ + pdebug(__func__, "requested pool (%s) have empty paths, closing connection", pool->name); + lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); + lm_mptp_server_send(sock, &packet, &saddr); + continue; + } + lm_pool_thread_arg_t *arg = malloc(sizeof(lm_pool_thread_arg_t)); memcpy(&arg->addr, &saddr, sizeof(struct sockaddr)); diff --git a/src/error.c b/src/error.c index 4ccaf37..8d7f4a0 100644 --- a/src/error.c +++ b/src/error.c @@ -67,6 +67,7 @@ char *lm_strerror() { {.code = LM_ERR_CtxDataNotDir, .desc = _("specified data path does not exist") }, {.code = LM_ERR_CtxDataNoWrite, .desc = _("specified data path is not a directory") }, {.code = LM_ERR_CtxDataFailMkdir, .desc = _("failed to create specified data directory") }, + {.code = LM_ERR_PoolTestNotPong, .desc = _("pool did not respond ping with pong") }, }; for (int i = 0; i < sizeof(errors) / sizeof(lm_error_desc_t); i++) { diff --git a/src/mptp/client.c b/src/mptp/client.c index 833d2e3..83f094b 100644 --- a/src/mptp/client.c +++ b/src/mptp/client.c @@ -2,7 +2,6 @@ #include "../../include/mptp.h" #include "../../include/util.h" -#include #include #include #include diff --git a/src/mptp/server.c b/src/mptp/server.c index 6c3d384..6b05344 100644 --- a/src/mptp/server.c +++ b/src/mptp/server.c @@ -2,7 +2,6 @@ #include "../../include/mptp.h" #include "../../include/util.h" -#include #include #include diff --git a/src/mptp/utils.c b/src/mptp/utils.c index b1fc2d2..7e4b788 100644 --- a/src/mptp/utils.c +++ b/src/mptp/utils.c @@ -1,19 +1,21 @@ #include "../../include/mptp.h" +#include "../../include/util.h" +#include #include +#include bool lm_mptp_sendfile(int sock, struct sockaddr *addr, char *path){ + if (NULL == path) + return false; + lm_mptp_t packet; bool ret = false; - if (NULL == path) { - lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); - goto end; - } - FILE *file = fopen(path, "r"); size_t read = 0; if(NULL == file){ + pdebug(__func__, "failed to open file: %s", path); lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); goto end; } @@ -36,13 +38,27 @@ end: } bool lm_mptp_recvfile(int sock, char *path){ + if(NULL == path) + return false; + + if(unlink(path) < 0 && errno != ENOENT) + return false; + FILE *file = fopen(path, "a"); bool ret = false; lm_mptp_t packet; + if(NULL == file){ + pdebug(__func__, "failed to open file: %s", path); + goto end; + } + while(lm_mptp_client_recv(sock, &packet)){ if(!lm_mptp_client_verify(&packet)) goto end; + + if(MPTP_FLAGS_CODE(&packet) != MPTP_S2C_COOL) + goto end; if(MPTP_IS_LAST(&packet)) break; diff --git a/src/pkg/data.c b/src/pkg/data.c index a6d7192..b3fa7e1 100644 --- a/src/pkg/data.c +++ b/src/pkg/data.c @@ -2,10 +2,10 @@ #include "../../include/util.h" #include "../../include/pkg.h" -#include #include #include #include +#include size_t lm_pkg_data_depend_count(lm_pkg_t *pkg){ size_t index = 0; diff --git a/src/pool/info.c b/src/pool/info.c index 4abb96a..8497fbb 100644 --- a/src/pool/info.c +++ b/src/pool/info.c @@ -3,13 +3,10 @@ #include "../../include/mptp.h" #include "../../include/util.h" -#include #include -#include #include #include #include -#include int lm_pool_info_handler(void *data, const char *_section, const char *_key, const char *_value) { char *section = (char *)_section, *value = (char *)_value, *key = (char *)_key; @@ -30,27 +27,42 @@ int lm_pool_info_handler(void *data, const char *_section, const char *_key, con return 1; } -bool lm_pool_info_load(lm_pool_t *pool, char *file) { +bool lm_pool_info_load(lm_pool_t *pool) { + if(NULL == pool){ + lm_error_set(LM_ERR_ArgNULL); + return false; + } + lm_pool_info_free(pool); - if(!can_read(file)){ + if(NULL == pool->paths.info) + return false; + + if(!can_read(pool->paths.info)){ lm_error_set(LM_ERR_PoolInfoCantRead); return false; } - if (ini_parse(file, lm_pool_info_handler, pool) < 0) { + if (ini_parse(pool->paths.info, lm_pool_info_handler, pool) < 0) { lm_error_set(LM_ERR_PoolInfoBad); return false; } - pool->paths.info = strdup(file); return true; } -bool lm_pool_info_get(lm_pool_t *pool, char *file) { +bool lm_pool_info_get(lm_pool_t *pool) { + if(NULL == pool){ + lm_error_set(LM_ERR_ArgNULL); + return false; + } + if(!pool->available) return false; + if(NULL == pool->paths.info) + return false; + if(NULL == pool->url.host) return false; @@ -67,15 +79,15 @@ bool lm_pool_info_get(lm_pool_t *pool, char *file) { if(!lm_mptp_client_send(sock, &packet)) goto end; - - if(!lm_mptp_recvfile(sock, file)) + + if(!lm_mptp_recvfile(sock, pool->paths.info)) goto end; ret = true; end: lm_mptp_close(sock); if(ret) - ret = lm_pool_info_load(pool, file); + ret = lm_pool_info_load(pool); return ret; } diff --git a/src/pool/list.c b/src/pool/list.c index 134cadb..39be6aa 100644 --- a/src/pool/list.c +++ b/src/pool/list.c @@ -4,29 +4,32 @@ #include "../../include/util.h" #include "../../include/pkg.h" +#include #include #include -#include #include -bool lm_pool_list_load(lm_pool_t *pool, char *file){ - if(NULL == pool || NULL == file){ +bool lm_pool_list_load(lm_pool_t *pool){ + if(NULL == pool){ lm_error_set(LM_ERR_ArgNULL); return false; } - if(!can_read(file)){ + if(NULL == pool->paths.list) + return false; + + if(!can_read(pool->paths.list)){ lm_error_set(LM_ERR_PoolListCantRead); return false; } - size_t file_len = strlen(file); + size_t file_len = strlen(pool->paths.list); char file_copy[file_len + 1]; char file_copy2[file_len + 1]; char *list_dir = NULL, *list_name = NULL; - memcpy(file_copy, file, file_len+1); - memcpy(file_copy2, file, file_len+1); + memcpy(file_copy, pool->paths.list, file_len+1); + memcpy(file_copy2, pool->paths.list, file_len+1); list_dir = dirname(file_copy); list_name = basename(file_copy2); @@ -46,7 +49,7 @@ bool lm_pool_list_load(lm_pool_t *pool, char *file){ DIR *dirfd = NULL; bool ret = false; - if(!extract_archive(extract_dir, file)) + if(!extract_archive(extract_dir, pool->paths.list)) goto end; if((dirfd = opendir(extract_dir)) == NULL){ @@ -87,7 +90,15 @@ end: return ret; } -bool lm_pool_list_get(lm_pool_t *pool, char *file) { +bool lm_pool_list_get(lm_pool_t *pool) { + if(NULL == pool){ + lm_error_set(LM_ERR_ArgNULL); + return false; + } + + if(NULL == pool->paths.list) + return false; + if(!pool->available) return false; @@ -108,13 +119,13 @@ bool lm_pool_list_get(lm_pool_t *pool, char *file) { if(!lm_mptp_client_send(sock, &packet)) goto end; - if(!lm_mptp_recvfile(sock, file)) + if(!lm_mptp_recvfile(sock, pool->paths.list)) goto end; ret = true; end: lm_mptp_close(sock); if(ret) - ret = lm_pool_list_load(pool, file); + ret = lm_pool_list_load(pool); return ret; } diff --git a/src/pool/paths.c b/src/pool/paths.c index b36f9f8..35e7b45 100644 --- a/src/pool/paths.c +++ b/src/pool/paths.c @@ -1,7 +1,9 @@ #include "../../include/types.h" +#include "../../include/pool.h" #include #include +#include void lm_pool_paths_set_info(lm_pool_t *pool, char *info_path){ free(pool->paths.info); @@ -21,6 +23,10 @@ void lm_pool_paths_set_list(lm_pool_t *pool, char *list_path){ pool->paths.list = strdup(list_path); } +bool lm_pool_paths_is_empty(lm_pool_t *pool){ + return NULL == pool->paths.info || NULL == pool->paths.list; +} + void lm_pool_paths_free(lm_pool_t *pool){ free(pool->paths.info); free(pool->paths.list); diff --git a/src/pool/pool.c b/src/pool/pool.c index f15231f..60f6aa7 100644 --- a/src/pool/pool.c +++ b/src/pool/pool.c @@ -56,6 +56,8 @@ void lm_pool_test(lm_pool_t *pool) { } pool->available = MPTP_FLAGS_CODE(&packet) == MPTP_S2C_PONG; + if(!pool->available) + lm_error_set(LM_ERR_PoolTestNotPong); end: lm_mptp_close(sock); return; diff --git a/src/pool/serve.c b/src/pool/serve.c index 53c7d0f..db212a7 100644 --- a/src/pool/serve.c +++ b/src/pool/serve.c @@ -28,7 +28,7 @@ void lm_pool_serve(lm_pool_t *pool, lm_mptp_t *packet, int sock, struct sockaddr // when LIST file is requested, send the file case MPTP_C2S_LIST: pdebug(__func__, "(%s) LIST from %s attempting to send list", pool->name, ipaddr); - lm_mptp_sendfile(sock, addr, pool->paths.list); + lm_mptp_sendfile(sock, addr, pool->paths.list); break; break; } diff --git a/src/url.c b/src/url.c index 84e0460..a695542 100644 --- a/src/url.c +++ b/src/url.c @@ -1,6 +1,7 @@ #include "../include/url.h" #include "../include/error.h" #include "../include/util.h" + #include #include #include diff --git a/src/util.c b/src/util.c index 802724d..020e698 100644 --- a/src/util.c +++ b/src/util.c @@ -5,16 +5,11 @@ #include #include #include -#include #include -#include #include #include #include #include -#include -#include -#include void pdebug(const char *func, const char *fmt, ...) { if (LM_DEBUG != 1)