File tree Expand file tree Collapse file tree 1 file changed +21
-11
lines changed
gix-transport/src/client/blocking_io/http/reqwest Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,20 @@ impl Default for Remote {
155
155
156
156
/// utilities
157
157
impl Remote {
158
+ fn restore_thread_after_failure ( & mut self ) -> http:: Error {
159
+ let err_that_brought_thread_down = self
160
+ . handle
161
+ . take ( )
162
+ . expect ( "thread handle present" )
163
+ . join ( )
164
+ . expect ( "handler thread should never panic" )
165
+ . expect_err ( "something should have gone wrong with curl (we join on error only)" ) ;
166
+ * self = Remote :: default ( ) ;
167
+ http:: Error :: InitHttpClient {
168
+ source : Box :: new ( err_that_brought_thread_down) ,
169
+ }
170
+ }
171
+
158
172
fn make_request (
159
173
& mut self ,
160
174
url : & str ,
@@ -179,14 +193,18 @@ impl Remote {
179
193
None => continue ,
180
194
} ;
181
195
}
182
- self . request
196
+ if self
197
+ . request
183
198
. send ( Request {
184
199
url : url. to_owned ( ) ,
185
200
headers : header_map,
186
201
upload_body_kind,
187
202
config : self . config . clone ( ) ,
188
203
} )
189
- . expect ( "the remote cannot be down at this point" ) ;
204
+ . is_err ( )
205
+ {
206
+ return Err ( self . restore_thread_after_failure ( ) ) ;
207
+ }
190
208
191
209
let Response {
192
210
headers,
@@ -195,15 +213,7 @@ impl Remote {
195
213
} = match self . response . recv ( ) {
196
214
Ok ( res) => res,
197
215
Err ( _) => {
198
- let err = self
199
- . handle
200
- . take ( )
201
- . expect ( "always present" )
202
- . join ( )
203
- . expect ( "no panic" )
204
- . expect_err ( "no receiver means thread is down with init error" ) ;
205
- * self = Self :: default ( ) ;
206
- return Err ( http:: Error :: InitHttpClient { source : Box :: new ( err) } ) ;
216
+ return Err ( self . restore_thread_after_failure ( ) ) ;
207
217
}
208
218
} ;
209
219
You can’t perform that action at this time.
0 commit comments