File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -492,8 +492,17 @@ impl<S: Read + Write> RawClient<S> {
492
492
493
493
// If the map is not empty, we select a random thread to become the
494
494
// new reader thread.
495
- if let Some ( sender) = map. values ( ) . next ( ) {
496
- sender. send ( ChannelMessage :: WakeUp ) ?;
495
+ if let Some ( err) = map. values ( ) . find_map ( |sender| {
496
+ sender
497
+ . send ( ChannelMessage :: WakeUp )
498
+ . map_err ( |err| {
499
+ warn ! ( "Unable to wake up a thread, trying some other" ) ;
500
+ err
501
+ } )
502
+ . err ( )
503
+ } ) {
504
+ error ! ( "All the threads has failed, giving up" ) ;
505
+ return Err ( err) ?;
497
506
}
498
507
499
508
break Ok ( resp) ;
Original file line number Diff line number Diff line change
1
+ use log:: error;
1
2
use std:: io:: { self , Read , Write } ;
2
3
use std:: sync:: { Arc , Mutex } ;
3
4
@@ -8,7 +9,10 @@ impl<T: Read + Write> Read for ClonableStream<T> {
8
9
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
9
10
self . 0
10
11
. lock ( )
11
- . map_err ( |_| io:: Error :: from ( io:: ErrorKind :: BrokenPipe ) ) ?
12
+ . map_err ( |_| {
13
+ error ! ( "Unable to acquire lock on ClonableStream read operation" ) ;
14
+ io:: Error :: from ( io:: ErrorKind :: BrokenPipe )
15
+ } ) ?
12
16
. read ( buf)
13
17
}
14
18
}
@@ -17,14 +21,20 @@ impl<T: Read + Write> Write for ClonableStream<T> {
17
21
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
18
22
self . 0
19
23
. lock ( )
20
- . map_err ( |_| io:: Error :: from ( io:: ErrorKind :: BrokenPipe ) ) ?
24
+ . map_err ( |_| {
25
+ error ! ( "Unable to acquire lock on ClonableStream write operation" ) ;
26
+ io:: Error :: from ( io:: ErrorKind :: BrokenPipe )
27
+ } ) ?
21
28
. write ( buf)
22
29
}
23
30
24
31
fn flush ( & mut self ) -> io:: Result < ( ) > {
25
32
self . 0
26
33
. lock ( )
27
- . map_err ( |_| io:: Error :: from ( io:: ErrorKind :: BrokenPipe ) ) ?
34
+ . map_err ( |_| {
35
+ error ! ( "Unable to acquire lock on ClonableStream flush operation" ) ;
36
+ io:: Error :: from ( io:: ErrorKind :: BrokenPipe )
37
+ } ) ?
28
38
. flush ( )
29
39
}
30
40
}
Original file line number Diff line number Diff line change @@ -344,6 +344,7 @@ impl Display for Error {
344
344
Error :: MissingDomain => f. write_str ( "Missing domain while it was explicitly asked to validate it" ) ,
345
345
Error :: BothSocksAndTimeout => f. write_str ( "Setting both a proxy and a timeout in `Config` is an error" ) ,
346
346
Error :: CouldntLockReader => f. write_str ( "Couldn't take a lock on the reader mutex. This means that there's already another reader thread is running" ) ,
347
+ Error :: Mpsc => f. write_str ( "Broken IPC communication channel: the other thread probably has exited" ) ,
347
348
}
348
349
}
349
350
}
@@ -367,7 +368,7 @@ impl_error!(bitcoin::consensus::encode::Error, Bitcoin);
367
368
368
369
impl < T > From < std:: sync:: PoisonError < T > > for Error {
369
370
fn from ( _: std:: sync:: PoisonError < T > ) -> Self {
370
- Error :: CouldntLockReader
371
+ Error :: IOError ( std :: io :: Error :: from ( std :: io :: ErrorKind :: BrokenPipe ) )
371
372
}
372
373
}
373
374
You can’t perform that action at this time.
0 commit comments