1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
$NetBSD: patch-hfile__libcurl.c,v 1.1 2020/07/22 14:50:14 bacon Exp $
# recent libcurl compatibility
--- hfile_libcurl.c.orig 2019-12-19 09:54:30.000000000 +0000
+++ hfile_libcurl.c
@@ -74,6 +74,10 @@ typedef struct {
unsigned int size;
} hdrlist;
+#ifndef ENOTRECOVERABLE
+#define ENOTRECOVERABLE EIO
+#endif
+
typedef struct {
hdrlist fixed; // List of headers supplied at hopen()
hdrlist extra; // List of headers from callback
@@ -218,6 +222,8 @@ static int easy_errno(CURL *easy, CURLco
return EEXIST;
default:
+ hts_log_error("Libcurl reported error %d (%s)", (int) err,
+ curl_easy_strerror(err));
return EIO;
}
}
@@ -238,6 +244,8 @@ static int multi_errno(CURLMcode errm)
return ENOMEM;
default:
+ hts_log_error("Libcurl reported error %d (%s)", (int) errm,
+ curl_multi_strerror(errm));
return EIO;
}
}
@@ -797,9 +805,13 @@ static ssize_t libcurl_read(hFILE *fpv,
fp->buffer.ptr.rd = buffer;
fp->buffer.len = nbytes;
fp->paused = 0;
- err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
- if (err != CURLE_OK) { errno = easy_errno(fp->easy, err); return -1; }
-
+ if (! fp->finished) {
+ err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
+ if (err != CURLE_OK) {
+ errno = easy_errno(fp->easy, err);
+ return -1;
+ }
+ }
while (! fp->paused && ! fp->finished) {
if (wait_perform(fp) < 0) return -1;
}
@@ -1003,12 +1015,6 @@ static int restart_from_position(hFILE_l
}
temp_fp.nrunning = ++fp->nrunning;
- err = curl_easy_pause(temp_fp.easy, CURLPAUSE_CONT);
- if (err != CURLE_OK) {
- save_errno = easy_errno(temp_fp.easy, err);
- goto error_remove;
- }
-
while (! temp_fp.paused && ! temp_fp.finished)
if (wait_perform(&temp_fp) < 0) {
save_errno = errno;
@@ -1084,8 +1090,10 @@ static int libcurl_close(hFILE *fpv)
fp->buffer.len = 0;
fp->closing = 1;
fp->paused = 0;
- err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
- if (err != CURLE_OK) save_errno = easy_errno(fp->easy, err);
+ if (! fp->finished) {
+ err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
+ if (err != CURLE_OK) save_errno = easy_errno(fp->easy, err);
+ }
while (save_errno == 0 && ! fp->paused && ! fp->finished)
if (wait_perform(fp) < 0) save_errno = errno;
|