@@ -28,6 +28,7 @@ use futures::future::AbortRegistration;
2828use futures:: future:: Abortable ;
2929use futures:: StreamExt ;
3030use opensrv_mysql:: * ;
31+ use socket2:: SockRef ;
3132use socket2:: TcpKeepalive ;
3233use tokio_stream:: wrappers:: TcpListenerStream ;
3334use tracing:: error;
@@ -92,7 +93,7 @@ impl MySQLHandler {
9293 sessions : Arc < SessionManager > ,
9394 executor : Arc < Runtime > ,
9495 socket : TcpStream ,
95- _keepalive : TcpKeepalive ,
96+ keepalive : TcpKeepalive ,
9697 ) {
9798 executor. spawn ( async move {
9899 match sessions. create_session ( SessionType :: MySQL ) . await {
@@ -103,11 +104,10 @@ impl MySQLHandler {
103104 Ok ( session) => {
104105 info ! ( "MySQL connection coming: {:?}" , socket. peer_addr( ) ) ;
105106
106- // FIXME: tokio TcpStream doesn't implement `AsFd` anymore, this call should be refactored.
107- // if let Err(e) = SockRef::from(&socket).set_tcp_keepalive(&keepalive)
108- // {
109- // warn!("failed to set socket option keepalive {}", e);
110- // }
107+ // TcpStream must implement AsFd for socket2 0.5, wait https://github.com/tokio-rs/tokio/pull/5514
108+ if let Err ( e) = SockRef :: from ( & socket) . set_tcp_keepalive ( & keepalive) {
109+ warn ! ( "failed to set socket option keepalive {}" , e) ;
110+ }
111111
112112 if let Err ( error) = MySQLConnection :: run_on_stream ( session, socket) {
113113 error ! ( "Unexpected error occurred during query: {:?}" , error) ;
0 commit comments