X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpaths.c;h=dcd7b493e129ec134e284f38fdca275cf8768dca;hp=3a69488e3e87e44dcd508a4ac4ba650d4c18571a;hb=0dca9e11c5bacd76a12b2e52a263ca7bd94b9a00;hpb=5314cebf5fe766bdca6c779e785b8dfaa3808142 diff --git a/discover/paths.c b/discover/paths.c index 3a69488..dcd7b49 100644 --- a/discover/paths.c +++ b/discover/paths.c @@ -3,11 +3,13 @@ #endif #include +#include #include #include #include -#include +#include #include +#include #include #include @@ -41,15 +43,6 @@ struct load_task { void *async_data; }; -static inline bool have_busybox(void) -{ -#ifdef WITH_BUSYBOX - return true; -#else - return false; -#endif -} - const char *mount_base(void) { return DEVICE_MOUNT_BASE; @@ -71,6 +64,12 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b) #ifndef PETITBOOT_TEST +#ifdef WITH_BUSYBOX +static inline bool have_busybox(void) { return true; } +#else +static inline bool have_busybox(void) { return false; } +#endif + static char *local_name(void *ctx) { char *ret, tmp[] = "/tmp/pb-XXXXXX"; @@ -119,6 +118,8 @@ static void load_url_process_exit(struct process *process) } else { result->status = LOAD_ERROR; load_url_result_cleanup_local(result); + pb_debug("Download client stdout buffer:\n%s\n", + process->stdout_buf); } if (result->status == LOAD_OK && process->stdout_data) @@ -436,16 +437,18 @@ static void load_wget(struct load_task *task, int flags) */ static void load_local(struct load_task *task) { + struct load_url_result *result = task->result; int rc; rc = access(task->url->path, F_OK); if (rc) { - task->result->status = LOAD_ERROR; + result->status = LOAD_ERROR; } else { - task->result->local = talloc_strdup(task->result, - task->url->path); - task->result->status = LOAD_OK; + result->local = talloc_strdup(task->result, task->url->path); + result->status = LOAD_OK; } + + task->async_cb(task->result, task->async_data); } static void load_url_async_start_pending(struct load_task *task, int flags) @@ -548,6 +551,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url, { struct load_url_result *result; struct load_task *task; + struct addrinfo *res; int flags = 0; if (!url) @@ -580,7 +584,8 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url, /* If the url is remote but network is not yet available queue up this * load for later */ - if (!system_info_network_available() && url->scheme != pb_url_file) { + if (url->scheme != pb_url_file && + getaddrinfo(url->host, NULL, NULL, &res) != 0) { pb_log("load task for %s queued pending network\n", url->full); pending_network_jobs_add(task, flags); task->result->status = LOAD_ASYNC; @@ -618,7 +623,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url, return NULL; } - if (!task->async) + if (!task->async || result->status == LOAD_OK) talloc_free(task); return result;