Lines Matching refs:per
298 static CURLcode add_per_transfer(struct per_transfer **per) in add_per_transfer() argument
315 *per = p; in add_per_transfer()
324 static struct per_transfer *del_per_transfer(struct per_transfer *per) in del_per_transfer() argument
330 DEBUGASSERT(per); in del_per_transfer()
332 n = per->next; in del_per_transfer()
333 p = per->prev; in del_per_transfer()
345 free(per); in del_per_transfer()
352 struct per_transfer *per) in pre_transfer() argument
358 if(per->uploadfile && !stdin_upload(per->uploadfile)) { in pre_transfer()
375 per->infd = -1; in pre_transfer()
376 if(stat(per->uploadfile, &fileinfo) == 0) { in pre_transfer()
382 per->infd = open(per->uploadfile, O_RDONLY | O_BINARY); in pre_transfer()
385 per->infd = open(per->uploadfile, O_RDONLY | O_BINARY, in pre_transfer()
389 if(per->infd == -1) in pre_transfer()
391 per->infd = open(per->uploadfile, O_RDONLY | O_BINARY); in pre_transfer()
392 if((per->infd == -1) || fstat(per->infd, &fileinfo)) in pre_transfer()
395 helpf(tool_stderr, "cannot open '%s'", per->uploadfile); in pre_transfer()
396 if(per->infd != -1) { in pre_transfer()
397 close(per->infd); in pre_transfer()
398 per->infd = STDIN_FILENO; in pre_transfer()
402 per->infdopen = TRUE; in pre_transfer()
420 struct OperationConfig *config = per->config; /* for the macro below */ in pre_transfer()
425 my_setopt(per->curl, CURLOPT_INFILESIZE_LARGE, uploadfilesize); in pre_transfer()
428 per->uploadfilesize = uploadfilesize; in pre_transfer()
429 per->start = tvnow(); in pre_transfer()
453 struct per_transfer *per, in post_per_transfer() argument
458 struct OutStruct *outs = &per->outs; in post_per_transfer()
459 CURL *curl = per->curl; in post_per_transfer()
460 struct OperationConfig *config = per->config; in post_per_transfer()
469 if(per->infdopen) in post_per_transfer()
470 close(per->infd); in post_per_transfer()
472 if(per->skip) in post_per_transfer()
485 const char *msg = per->errorbuffer; in post_per_transfer()
505 rc = fwrite_xattr(curl, per->url, fileno(outs->stream)); in post_per_transfer()
541 if(per->retry_remaining && in post_per_transfer()
543 (tvdiff(tvnow(), per->retrystart) < in post_per_transfer()
634 sleeptime = per->retry_sleep; in post_per_transfer()
648 curl_off_t seconds = tvdiff(tvnow(), per->retrystart)/1000; in post_per_transfer()
663 m[retry], sleeptime/1000L, per->retry_remaining); in post_per_transfer()
665 per->retry_remaining--; in post_per_transfer()
667 per->retry_sleep *= 2; in post_per_transfer()
668 if(per->retry_sleep > RETRY_SLEEP_MAX) in post_per_transfer()
669 per->retry_sleep = RETRY_SLEEP_MAX; in post_per_transfer()
703 per->num_retries++; in post_per_transfer()
711 per->progressbar.calls) in post_per_transfer()
714 fputs("\n", per->progressbar.out); in post_per_transfer()
749 ourWriteOut(config, per, result); in post_per_transfer()
752 if(per->heads.fopened && per->heads.stream) in post_per_transfer()
753 fclose(per->heads.stream); in post_per_transfer()
755 if(per->heads.alloc_filename) in post_per_transfer()
756 Curl_safefree(per->heads.filename); in post_per_transfer()
758 if(per->etag_save.fopened && per->etag_save.stream) in post_per_transfer()
759 fclose(per->etag_save.stream); in post_per_transfer()
761 if(per->etag_save.alloc_filename) in post_per_transfer()
762 Curl_safefree(per->etag_save.filename); in post_per_transfer()
764 curl_easy_cleanup(per->curl); in post_per_transfer()
767 free(per->url); in post_per_transfer()
768 free(per->outfile); in post_per_transfer()
769 free(per->uploadfile); in post_per_transfer()
771 free(per->errorbuffer); in post_per_transfer()
772 curl_slist_free_all(per->hdrcbdata.headlist); in post_per_transfer()
773 per->hdrcbdata.headlist = NULL; in post_per_transfer()
882 struct per_transfer *per, in config2setopts() argument
888 CURLcode result = url_proto_and_rewrite(&per->url, config, &use_proto); in config2setopts()
918 my_setopt(curl, CURLOPT_WRITEDATA, per); in config2setopts()
919 my_setopt(curl, CURLOPT_INTERLEAVEDATA, per); in config2setopts()
931 my_setopt(curl, CURLOPT_READDATA, per); in config2setopts()
937 my_setopt(curl, CURLOPT_SEEKDATA, per); in config2setopts()
958 my_setopt_str(curl, CURLOPT_URL, per->url); in config2setopts()
1009 my_setopt(curl, CURLOPT_UPLOAD, per->uploadfile ? 1L : 0L); in config2setopts()
1029 per->errorbuffer = global_errorbuffer; in config2setopts()
1421 progressbarinit(&per->progressbar, config); in config2setopts()
1428 my_setopt(curl, CURLOPT_XFERINFODATA, per); in config2setopts()
1430 else if(per->uploadfile && !strcmp(per->uploadfile, ".")) { in config2setopts()
1435 my_setopt(curl, CURLOPT_XFERINFODATA, per); in config2setopts()
1636 my_setopt(curl, CURLOPT_HEADERDATA, per); in config2setopts()
1769 struct per_transfer *per, in append2query() argument
1776 uerr = curl_url_set(uh, CURLUPART_URL, per->url, in append2query()
1793 Curl_safefree(per->url); /* free previous URL */ in append2query()
1794 per->url = updated; /* use our new URL instead! */ in append2query()
1922 struct per_transfer *per = NULL; in single_transfer() local
2005 result = add_per_transfer(&per); in single_transfer()
2014 per->etag_save = etag_first; /* copy the whole struct */ in single_transfer()
2016 per->uploadfile = strdup(state->uploadfile); in single_transfer()
2017 if(!per->uploadfile) { in single_transfer()
2023 Curl_safefree(per->uploadfile); in single_transfer()
2030 per->config = config; in single_transfer()
2031 per->curl = curl; in single_transfer()
2032 per->urlnum = (unsigned int)urlnode->num; in single_transfer()
2035 heads = &per->heads; in single_transfer()
2064 if(!per->prev || per->prev->config != config) { in single_transfer()
2089 hdrcbdata = &per->hdrcbdata; in single_transfer()
2091 outs = &per->outs; in single_transfer()
2093 per->outfile = NULL; in single_transfer()
2094 per->infdopen = FALSE; in single_transfer()
2095 per->infd = STDIN_FILENO; in single_transfer()
2101 result = glob_next_url(&per->url, state->urls); in single_transfer()
2106 per->url = strdup(urlnode->url); in single_transfer()
2107 if(!per->url) { in single_transfer()
2113 per->url = NULL; in single_transfer()
2114 if(!per->url) in single_transfer()
2118 per->outfile = strdup(state->outfiles); in single_transfer()
2119 if(!per->outfile) { in single_transfer()
2126 (per->outfile && strcmp("-", per->outfile)))) { in single_transfer()
2133 if(!per->outfile) { in single_transfer()
2135 result = get_url_file_name(global, &per->outfile, per->url); in single_transfer()
2144 char *storefile = per->outfile; in single_transfer()
2145 result = glob_match_url(&per->outfile, storefile, state->urls); in single_transfer()
2152 if(!*per->outfile) { in single_transfer()
2158 DEBUGASSERT(per->outfile); in single_transfer()
2161 char *d = aprintf("%s/%s", config->output_dir, per->outfile); in single_transfer()
2166 free(per->outfile); in single_transfer()
2167 per->outfile = d; in single_transfer()
2173 result = create_dir_hierarchy(per->outfile, global); in single_transfer()
2181 if(!stat(per->outfile, &fileinfo)) { in single_transfer()
2184 per->outfile); in single_transfer()
2185 per->skip = TRUE; in single_transfer()
2200 if(0 == stat(per->outfile, &fileinfo)) in single_transfer()
2216 FILE *file = fopen(per->outfile, "ab"); in single_transfer()
2219 errorf(global, "cannot open '%s'", per->outfile); in single_transfer()
2230 outs->filename = per->outfile; in single_transfer()
2234 if(per->uploadfile && !stdin_upload(per->uploadfile)) { in single_transfer()
2238 result = add_file_name_to_url(per->curl, &per->url, in single_transfer()
2239 per->uploadfile); in single_transfer()
2243 else if(per->uploadfile && stdin_upload(per->uploadfile)) { in single_transfer()
2269 DEBUGASSERT(per->infdopen == FALSE); in single_transfer()
2270 DEBUGASSERT(per->infd == STDIN_FILENO); in single_transfer()
2273 if(!strcmp(per->uploadfile, ".")) { in single_transfer()
2274 if(curlx_nonblock((curl_socket_t)per->infd, TRUE) < 0) in single_transfer()
2276 "fcntl failed on fd=%d: %s", per->infd, strerror(errno)); in single_transfer()
2280 if(per->uploadfile && config->resume_from_current) in single_transfer()
2283 if(output_expected(per->url, per->uploadfile) && outs->stream && in single_transfer()
2287 per->noprogress = global->noprogress = global->isatty = TRUE; in single_transfer()
2291 per->noprogress = global->noprogress = orig_noprogress; in single_transfer()
2296 result = append2query(global, config, per, in single_transfer()
2302 if((!per->outfile || !strcmp(per->outfile, "-")) && in single_transfer()
2311 (per->outfile && !strcmp(per->outfile, "-")); in single_transfer()
2324 result = config2setopts(global, config, per, capath_from_env, in single_transfer()
2330 per->retry_sleep_default = (config->retry_delay) ? in single_transfer()
2332 per->retry_remaining = config->req_retry; in single_transfer()
2333 per->retry_sleep = per->retry_sleep_default; /* ms */ in single_transfer()
2334 per->retrystart = tvnow(); in single_transfer()
2384 struct per_transfer *per; in add_parallel_transfers() local
2399 for(per = transfers; per && (all_added < global->parallel_max); in add_parallel_transfers()
2400 per = per->next) { in add_parallel_transfers()
2401 if(per->added || per->skip) in add_parallel_transfers()
2404 if(per->startat && (time(NULL) < per->startat)) { in add_parallel_transfers()
2409 per->added = TRUE; in add_parallel_transfers()
2411 result = pre_transfer(global, per); in add_parallel_transfers()
2421 (void)curl_easy_setopt(per->curl, CURLOPT_PIPEWAIT, in add_parallel_transfers()
2423 (void)curl_easy_setopt(per->curl, CURLOPT_PRIVATE, per); in add_parallel_transfers()
2424 (void)curl_easy_setopt(per->curl, CURLOPT_XFERINFOFUNCTION, xferinfo_cb); in add_parallel_transfers()
2425 (void)curl_easy_setopt(per->curl, CURLOPT_XFERINFODATA, per); in add_parallel_transfers()
2426 (void)curl_easy_setopt(per->curl, CURLOPT_NOPROGRESS, 0L); in add_parallel_transfers()
2429 (void)curl_easy_setopt(per->curl, CURLOPT_FORBID_REUSE, 1L); in add_parallel_transfers()
2432 mcode = curl_multi_add_handle(multi, per->curl); in add_parallel_transfers()
2452 (void)curl_easy_setopt(per->curl, CURLOPT_ERRORBUFFER, errorbuf); in add_parallel_transfers()
2453 per->errorbuffer = errorbuf; in add_parallel_transfers()
2454 per->added = TRUE; in add_parallel_transfers()
2458 *morep = (per || sleeping); in add_parallel_transfers()
2674 struct per_transfer *per; in parallel_event() local
2675 for(per = transfers; per; per = per->next) { in parallel_event()
2676 if(per->added) in parallel_event()
2677 per->abort = TRUE; in parallel_event()
2817 struct per_transfer *per; in parallel_transfers() local
2818 for(per = transfers; per; per = per->next) { in parallel_transfers()
2819 if(per->added) in parallel_transfers()
2820 per->abort = TRUE; in parallel_transfers()
2854 struct per_transfer *per; in serial_transfers() local
2865 for(per = transfers; per;) { in serial_transfers()
2872 if(!per->skip) { in serial_transfers()
2873 result = pre_transfer(global, per); in serial_transfers()
2885 (void)curl_easy_setopt(per->curl, CURLOPT_FORBID_REUSE, 1L); in serial_transfers()
2888 CURL *dup = curl_easy_duphandle(per->curl); in serial_transfers()
2889 curl_easy_cleanup(per->curl); in serial_transfers()
2890 per->curl = dup; in serial_transfers()
2896 (void)curl_easy_setopt(per->curl, CURLOPT_SHARE, share); in serial_transfers()
2899 result = curl_easy_perform_ev(per->curl); in serial_transfers()
2902 result = curl_easy_perform(per->curl); in serial_transfers()
2905 returncode = post_per_transfer(global, per, result, &retry, &delay_ms); in serial_transfers()
2926 per = del_per_transfer(per); in serial_transfers()
2931 if(per && global->ms_per_transfer) { in serial_transfers()
3120 struct per_transfer *per; in run_all_transfers() local
3131 for(per = transfers; per;) { in run_all_transfers()
3134 CURLcode result2 = post_per_transfer(global, per, result, &retry, &delay); in run_all_transfers()
3140 clean_getout(per->config); in run_all_transfers()
3142 per = del_per_transfer(per); in run_all_transfers()