summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5241bfe)
raw | patch | inline | side by side (parent: 5241bfe)
author | Nick Hengeveld <nickh@reactrix.com> | |
Sat, 11 Mar 2006 04:18:01 +0000 (20:18 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 11 Mar 2006 07:01:48 +0000 (23:01 -0800) |
Incorporate into http-push a fix related to accessing slot results after
the slot was reused, and fix a case in run_active_slot where a
finished slot wasn't detected if the slot was reused.
Signed-off-by: Junio C Hamano <junkio@cox.net>
the slot was reused, and fix a case in run_active_slot where a
finished slot wasn't detected if the slot was reused.
Signed-off-by: Junio C Hamano <junkio@cox.net>
http-push.c | patch | blob | history | |
http.c | patch | blob | history | |
http.h | patch | blob | history |
diff --git a/http-push.c b/http-push.c
index 4c1b0c3039a84c4c786a09ba70a84df46f995186..78129ec0cd5fb9767caefee8a8dc1a17dc095bdb 100644 (file)
--- a/http-push.c
+++ b/http-push.c
static int refresh_lock(struct remote_lock *check_lock)
{
struct active_request_slot *slot;
+ struct slot_results results;
char *if_header;
char timeout_header[25];
struct curl_slist *dav_headers = NULL;
dav_headers = curl_slist_append(dav_headers, timeout_header);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
curl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
- fprintf(stderr, "Got HTTP error %ld\n", slot->http_code);
+ if (results.curl_result != CURLE_OK) {
+ fprintf(stderr, "Got HTTP error %ld\n", results.http_code);
lock->active = 0;
} else {
lock->active = 1;
FILE *indexfile;
struct active_request_slot *slot;
+ struct slot_results results;
/* Don't use the index if the pack isn't there */
url = xmalloc(strlen(remote->url) + 65);
sprintf(url, "%s/objects/pack/pack-%s.pack", remote->url, hex);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
free(url);
return error("Unable to verify pack %s is available",
hex);
filename);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
free(url);
fclose(indexfile);
return error("Unable to get pack index %s\n%s", url,
int i = 0;
struct active_request_slot *slot;
+ struct slot_results results;
data = xmalloc(4096);
memset(data, 0, 4096);
sprintf(url, "%s/objects/info/packs", remote->url);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
free(buffer.buffer);
free(url);
- if (slot->http_code == 404)
+ if (results.http_code == 404)
return 0;
else
return error("%s", curl_errorstr);
struct buffer buffer;
char *base = remote->url;
struct active_request_slot *slot;
+ struct slot_results results;
buffer.size = 41;
buffer.posn = 0;
buffer.buffer = hex;
hex[41] = '\0';
-
+
url = quote_ref_url(base, ref);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK)
+ if (results.curl_result != CURLE_OK)
return error("Couldn't get %s for %s\n%s",
url, ref, curl_errorstr);
} else {
static struct remote_lock *lock_remote(char *path, long timeout)
{
struct active_request_slot *slot;
+ struct slot_results results;
struct buffer out_buffer;
struct buffer in_buffer;
char *out_data;
while (ep) {
*ep = 0;
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK &&
- slot->http_code != 405) {
+ if (results.curl_result != CURLE_OK &&
+ results.http_code != 405) {
fprintf(stderr,
"Unable to create branch path %s\n",
url);
dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result == CURLE_OK) {
+ if (results.curl_result == CURLE_OK) {
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
static int unlock_remote(struct remote_lock *lock)
{
struct active_request_slot *slot;
+ struct slot_results results;
char *lock_token_header;
struct curl_slist *dav_headers = NULL;
int rc = 0;
dav_headers = curl_slist_append(dav_headers, lock_token_header);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
curl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);
curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_UNLOCK);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result == CURLE_OK)
+ if (results.curl_result == CURLE_OK)
rc = 1;
else
fprintf(stderr, "Got HTTP error %ld\n",
- slot->http_code);
+ results.http_code);
} else {
fprintf(stderr, "Unable to start request\n");
}
{
char *url;
struct active_request_slot *slot;
+ struct slot_results results;
struct buffer in_buffer;
struct buffer out_buffer;
char *in_data;
dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result == CURLE_OK) {
+ if (results.curl_result == CURLE_OK) {
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
{
char *url;
struct active_request_slot *slot;
+ struct slot_results results;
struct buffer in_buffer;
struct buffer out_buffer;
char *in_data;
dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result == CURLE_OK) {
+ if (results.curl_result == CURLE_OK) {
remote_dir_exists[parent] = 1;
ctx.name = xcalloc(10, 1);
ctx.len = 0;
static int locking_available(void)
{
struct active_request_slot *slot;
+ struct slot_results results;
struct buffer in_buffer;
struct buffer out_buffer;
char *in_data;
dav_headers = curl_slist_append(dav_headers, "Depth: 0");
dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
-
+
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result == CURLE_OK) {
+ if (results.curl_result == CURLE_OK) {
ctx.name = xcalloc(10, 1);
ctx.len = 0;
ctx.cdata = NULL;
static int update_remote(unsigned char *sha1, struct remote_lock *lock)
{
struct active_request_slot *slot;
+ struct slot_results results;
char *out_data;
char *if_header;
struct buffer out_buffer;
out_buffer.buffer = out_data;
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
run_active_slot(slot);
free(out_data);
free(if_header);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
fprintf(stderr,
"PUT error: curl result=%d, HTTP code=%ld\n",
- slot->curl_result, slot->http_code);
+ results.curl_result, results.http_code);
/* We should attempt recovery? */
return 0;
}
index 14a7669cd427e101985d4acf8f3da3314937eeaa..9604e3326bbc902aed987d2816fdf25450203633 100644 (file)
--- a/http.c
+++ b/http.c
slot->in_use = 1;
slot->local = NULL;
slot->results = NULL;
+ slot->finished = NULL;
slot->callback_data = NULL;
slot->callback_func = NULL;
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
fd_set excfds;
int max_fd;
struct timeval select_timeout;
+ int finished = 0;
- while (slot->in_use) {
+ slot->finished = &finished;
+ while (!finished) {
data_received = 0;
step_active_slots();
closedown_active_slot(slot);
curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
+ if (slot->finished != NULL)
+ (*slot->finished) = 1;
+
/* Store slot results so they can be read after the slot is reused */
if (slot->results != NULL) {
slot->results->curl_result = slot->curl_result;