@@ -153,10 +153,7 @@ impl<Fs, RwExt> ServerInstance<Fs, RwExt>
153153 let msg = serialize:: read_msg ( & mut self . stream ) ?;
154154
155155 debug ! ( "\t → {:?}" , msg) ;
156- let ( fcall, tag) = dispatch_once (
157- msg,
158- & mut self . fs ,
159- & mut self . fids ) ?;
156+ let ( fcall, tag) = dispatch_once ( msg, & mut self . fs , & mut self . fids ) ?;
160157
161158 utils:: respond ( & mut self . stream , tag, fcall) ?;
162159 }
@@ -183,14 +180,12 @@ impl<Fs, RwExt> SpawnServerInstance<Fs, RwExt>
183180
184181 fn dispatch ( & mut self ) -> Result < ( ) > {
185182 loop {
183+ //let msg = serialize::read_msg(&mut self.stream)?;
186184 let msg = serialize:: read_msg ( & mut self . stream ) ?;
187185
188186 debug ! ( "\t → {:?}" , msg) ;
189- let ( fcall, tag) = dispatch_once (
190- msg,
191- & mut * self . fs . lock ( ) . unwrap ( ) ,
192- & mut self . fids
193- ) ?;
187+ let ( fcall, tag) =
188+ dispatch_once ( msg, & mut * self . fs . lock ( ) . unwrap ( ) , & mut self . fids ) ?;
194189
195190 utils:: respond ( & mut self . stream , tag, fcall) ?;
196191 }
@@ -302,9 +297,8 @@ pub fn srv<Fs: Filesystem>(filesystem: Fs, addr: &str) -> Result<()> {
302297/// This function spawns a new thread to handle its 9P messages
303298/// when a client connects to the server.
304299pub fn srv_spawn < Fs : Filesystem + Send + ' static > ( filesystem : Fs , addr : & str ) -> Result < ( ) > {
305- let ( proto, sockaddr) = utils:: parse_proto ( addr) . ok_or (
306- io_err ! ( InvalidInput , "Invalid protocol or address" )
307- ) ?;
300+ let ( proto, sockaddr) = utils:: parse_proto ( addr)
301+ . ok_or ( io_err ! ( InvalidInput , "Invalid protocol or address" ) ) ?;
308302
309303 if proto != "tcp" {
310304 return res ! ( io_err!( InvalidInput , format!( "Unsupported protocol: {}" , proto) ) ) ;
@@ -315,14 +309,15 @@ pub fn srv_spawn<Fs: Filesystem + Send + 'static>(filesystem: Fs, addr: &str) ->
315309
316310 loop {
317311 let ( stream, remote) = listener. accept ( ) ?;
318- let ( fs, thread_name) = ( arc_fs. clone ( ) , format ! ( "{}" , remote) ) ;
312+ let ( fs, thread_name) = ( arc_fs. clone ( ) , remote. to_string ( ) ) ;
319313
320314 let _ = thread:: Builder :: new ( ) . name ( thread_name. clone ( ) ) . spawn ( move || {
321315 info ! ( "ServerThread={:?} started" , thread_name) ;
322- let result = { || {
323- utils:: setup_tcp_stream ( & stream) ?;
324- SpawnServerInstance :: new ( fs, stream) ?. dispatch ( )
325- } } ( ) ;
316+
317+ let result = utils:: setup_tcp_stream ( & stream)
318+ . map_err ( From :: from)
319+ . and_then ( |_| SpawnServerInstance :: new ( fs, stream) ?. dispatch ( ) ) ;
320+
326321 info ! ( "ServerThread={:?} finished: {:?}" , thread_name, result) ;
327322 } ) ;
328323 }
0 commit comments