@@ -76,16 +76,13 @@ impl QueryResult {
7676
7777 /// Fetch data from table. It returns a block that contains all rows.
7878 pub fn fetch_all ( self ) -> BoxFuture < ( ClientHandle , Block ) > {
79- let timeout = try_opt ! ( self . client. context. options. get( ) ) . query_timeout ;
80-
8179 wrap_future (
8280 self . fold_blocks ( Vec :: new ( ) , |mut blocks, block| {
8381 if !block. is_empty ( ) {
8482 blocks. push ( block) ;
8583 }
8684 Ok ( blocks)
8785 } )
88- . timeout ( timeout)
8986 . map_err ( Error :: from)
9087 . map ( |( h, blocks) | ( h, Block :: concat ( blocks. as_slice ( ) ) ) )
9188 )
@@ -99,6 +96,7 @@ impl QueryResult {
9996 Fut :: Future : Send ,
10097 T : Send + ' static ,
10198 {
99+ let timeout = try_opt ! ( self . client. context. options. get( ) ) . query_timeout ;
102100 let context = self . client . context . clone ( ) ;
103101 let pool = self . client . pool . clone ( ) ;
104102 let release_pool = self . client . pool . clone ( ) ;
@@ -122,9 +120,10 @@ impl QueryResult {
122120 _ => Either :: Right ( future:: err ( Error :: Driver ( DriverError :: UnexpectedPacket ) ) ) ,
123121 } )
124122 . map ( |( c, t) | ( c. unwrap ( ) , t) )
123+ . timeout ( timeout)
125124 . map_err ( move |err| {
126125 release_pool. release_conn ( ) ;
127- err
126+ err. into ( )
128127 } ) ,
129128 )
130129 }
@@ -187,6 +186,7 @@ impl QueryResult {
187186
188187 let context = c. context . clone ( ) ;
189188 let pool = c. pool . clone ( ) ;
189+ let release_pool = c. pool . clone ( ) ;
190190
191191 BlockStream :: new (
192192 c. inner
@@ -197,7 +197,10 @@ impl QueryResult {
197197 pool,
198198 )
199199 . timeout ( timeout)
200- . map_err ( Error :: from)
200+ . map_err ( move |err| {
201+ release_pool. clone ( ) . release_conn ( ) ;
202+ err. into ( )
203+ } )
201204 } )
202205 }
203206
0 commit comments