Skip to content

Commit

Permalink
fixup! WIP: libcurl backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Jan 24, 2017
1 parent a9aa678 commit 27bf8f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
23 changes: 13 additions & 10 deletions src/libostree/ostree-fetcher-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ request_unref (FetcherRequest *req)
g_ptr_array_unref (req->mirrorlist);
g_free (req->filename);
g_clear_error (&req->caught_write_error);
if (req->out_tmpfile_fd != -1)
(void) close (req->out_tmpfile_fd);
g_free (req->out_tmpfile);
if (req->output_buf)
g_string_free (req->output_buf, TRUE);
Expand Down Expand Up @@ -782,17 +784,12 @@ _ostree_fetcher_request_async (OstreeFetcher *self,
req->max_size = max_size;
req->flags = flags;
req->is_membuf = is_membuf;
/* We'll allocate the tmpfile on demand, so we handle
* file I/O errors just in the write func.
*/
req->out_tmpfile_fd = -1;
if (req->is_membuf)
{
req->output_buf = g_string_new ("");
}
else
{
/* We'll allocate the tmpfile on demand, so we handle
* file I/O errors just in the write func.
*/
req->out_tmpfile_fd = -1;
}
req->output_buf = g_string_new ("");

task = g_task_new (self, cancellable, callback, user_data);
/* We'll use the GTask priority for our own priority queue. */
Expand All @@ -803,6 +800,12 @@ _ostree_fetcher_request_async (OstreeFetcher *self,
initiate_next_curl_request (req, task);

g_hash_table_add (self->outstanding_requests, g_steal_pointer (&task));

/* Sanity check, I added * 2 just so we don't abort if something odd happens,
* but we do want to abort if we're asked to do obviously too many requests.
*/
g_assert_cmpint (g_hash_table_size (self->outstanding_requests), <,
_OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS * 2);
}

void
Expand Down
3 changes: 3 additions & 0 deletions src/libostree/ostree-repo-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ G_BEGIN_DECLS
#define _OSTREE_SUMMARY_CACHE_DIR "summaries"
#define _OSTREE_CACHE_DIR "cache"

#define _OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS 8
#define _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS 2

typedef enum {
OSTREE_REPO_TEST_ERROR_PRE_COMMIT = (1 << 0)
} OstreeRepoTestErrorFlags;
Expand Down
7 changes: 2 additions & 5 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@

#include <gio/gunixinputstream.h>

#define MAX_OUTSTANDING_REQUESTS 8
#define MAX_OUTSTANDING_DELTAPART_REQUESTS 2

#define OSTREE_REPO_PULL_CONTENT_PRIORITY (OSTREE_FETCHER_DEFAULT_PRIORITY)
#define OSTREE_REPO_PULL_METADATA_PRIORITY (OSTREE_REPO_PULL_CONTENT_PRIORITY - 100)

Expand Down Expand Up @@ -355,7 +352,7 @@ fetcher_queue_is_full (OtPullData *pull_data)
{
return (pull_data->n_outstanding_metadata_fetches +
pull_data->n_outstanding_content_fetches +
pull_data->n_outstanding_deltapart_fetches) == MAX_OUTSTANDING_REQUESTS ||
pull_data->n_outstanding_deltapart_fetches) == _OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS ||
pull_data->n_outstanding_deltapart_fetches > 1;
}

Expand Down Expand Up @@ -1627,7 +1624,7 @@ start_fetch_deltapart (OtPullData *pull_data,
{
g_autofree char *deltapart_path = _ostree_get_relative_static_delta_part_path (fetch->from_revision, fetch->to_revision, fetch->i);
pull_data->n_outstanding_deltapart_fetches++;
g_assert_cmpint (pull_data->n_outstanding_deltapart_fetches, <=, MAX_OUTSTANDING_DELTAPART_REQUESTS);
g_assert_cmpint (pull_data->n_outstanding_deltapart_fetches, <=, _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS);
_ostree_fetcher_request_to_tmpfile (pull_data->fetcher,
pull_data->content_mirrorlist,
deltapart_path, fetch->size,
Expand Down

0 comments on commit 27bf8f1

Please sign in to comment.