ITADN

ntex websocket test server shutdown result in error: pthread lock: Invalid argument

#688Opengftea 创建于 2025-12-09
G
gfteacommented
- Test case ```rust #[ntex::test] async fn test_eth_ws_authentication() { let _ = supra_logger::init_default_logger(LevelFilter::OFF); let token_str = "secret-token"; let ws_auth_tokens = vec![token_str.to_string()]; let srv = http::test::server({ let ws_auth_tokens = ws_auth_tokens.clone(); move || { let (_executor_with_resources, web_service) = block_on(setup_executor_with_web_service_with_ws_auth( TestArchiveState::Empty, &[], &Default::default(), &ws_auth_tokens, )); http::HttpService::build().finish(web::App::new().service(web_service)) } }); let no_auth = ntex::ws::WsClient::build(srv.url("/rpc/v1/eth")) .address(srv.addr()) .header(http::header::HOST, "localhost") .timeout(Seconds(5)) .keepalive_timeout(Seconds(5)) .finish() .unwrap() .connect() .await .expect("anonymous connection should succeed"); let wrong_auth = ntex::ws::WsClient::build(srv.url("/rpc/v1/eth")) .address(srv.addr()) .header(http::header::HOST, "localhost") .header(http::header::AUTHORIZATION, "Bearer wrong-token") .timeout(Seconds(5)) .keepalive_timeout(Seconds(5)) .finish() .unwrap() .connect() .await .expect("connection with unknown token should use anonymous slot"); let client = ntex::ws::WsClient::build(srv.url("/rpc/v1/eth")) .address(srv.addr()) .header(http::header::HOST, "localhost") .header(http::header::AUTHORIZATION, format!("Bearer {token_str}")) .timeout(Seconds(5)) .keepalive_timeout(Seconds(5)) .finish() .unwrap() .connect() .await .expect("connection with valid token should succeed"); for conn in [no_auth, wrong_auth, client] { let conn = conn.seal(); let tx = conn.sink(); let rx = conn.receiver(); tx.send(ws::Message::Close(None)).await.unwrap(); let _ = rx.recv().await; } } ``` ## Errors ``` test rest::evm::eth_ws_jsonrpc::test_eth_ws_authentication ... ok ``` ``` test result: ok[2025-12-09T13:34:57.943965Z+00:00] TRACE tokio::task::waker: op="waker.drop" task.id=13 . 1 passed; 0 failed; 0 ignored; 0 measured; 37 filtered out; finished in 3.06s[2025-12-09T13:34:57.943970Z+00:00] TRACE runtime.resource{concrete_type="Sender|Receiver" kind="Sync" loc.file="/home/ubuntu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/blocking/shutdown.rs" loc.line=22 loc.col=20}: runtime::resource::state_update: tx_dropped=true tx_dropped.op="override" [2025-12-09T13:34:57.943973Z+00:00] TRACE tokio::task::waker: op="waker.drop" task.id=12 [2025-12-09T13:34:57.943988Z+00:00] TRACE runtime.resource{concrete_type="Sender|Receiver" kind="Sync" loc.file="/home/ubuntu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/blocking/shutdown.rs" loc.line=22 loc.col=20}:runtime.resource.async_op{source="Receiver::await"}:runtime.resource.async_op.poll: runtime::resource::poll_op: op_name="poll_recv" is_ready=true [2025-12-09T13:34:57.944015Z+00:00] TRACE tokio::task::waker: op="waker.drop" task.id=11 [2025-12-09T13:34:57.944020Z+00:00] TRACE tokio::task::waker: op="waker.drop" task.id=10 [2025-12-09T13:34:57.944044Z+00:00] TRACE runtime.spawn{kind=local task.name= task.id=15 original_size.bytes=2248 size.bytes=8 loc.file="/home/ubuntu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ntex-rt-0.4.32/src/lib.rs" loc.line=88 loc.col=9}: tokio::task::waker: op="waker.wake" task.id=6 stderr ─── [DEBUG ntex_rt::tokio] Create tokio runtime and block on future [TRACE tokio::sync::oneshot] runtime.resource; concrete_type="Sender|Receiver" kind="Sync" loc.file="/home/ubuntu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/blocking/shutdown.rs" loc.line=22 loc.col=20 [TRACE tracing::span::active] -> runtime.resource; [TRACE runtime::resource::state_update] tx_dropped=false tx_dropped.op="override" [TRACE tracing::span::active] <- runtime.resource; [TRACE tracing::span::active] -> runtime.resource; [TRACE runtime::resource::state_update] rx_dropped=false rx_dropped.op="override" [TRACE tracing::span::active] <- runtime.resource; [TRACE tracing::span::active] -> runtime.resource; [TRACE runtime::resource::state_update] value_sent=false value_sent.op="override" [TRACE ntex::ws::client] WS-CLIENT: Ws handshake response is received ResponseHead { version: HTTP/1.1, status: 101, headers: {"date": "Tue, 09 Dec 2025 13:34:57 GMT", "upgrade": "websocket", "connection": "upgrade", "transfer-encoding": "chunked", "sec-websocket-accept": "XXehqXurlUoqR04QxJ6DhSdeq6I="}, reason: None, io: None, extensions: RefCell { value: Extensions { size: 0 } }, flags: Flags(UPGRADE) } [TRACE ntex::ws::client] WS-CLIENT: Ws handshake response verification is completed [TRACE ntex_io::dispatcher] WS-CLIENT: Start keep-alive timer Seconds(5) [TRACE ntex_io::ioref] WS-CLIENT: Start timer Seconds(5) [DEBUG ntex_io::timer] WS-CLIENT: Timer driver does not run, current: 0 [TRACE ntex_io::tasks] HTTP-TEST-SRV: New 6 bytes available, wakeup dispatcher [TRACE ntex_io::io] HTTP-TEST-SRV: Initiate io shutdown Flags(DSP_STOP) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Dispatcher is instructed to stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Stop timer [TRACE ntex_io::tasks] HTTP-TEST-SRV: Read io is closed, stop read task [TRACE ntex_io::tasks] HTTP-TEST-SRV: Write task is instructed to shutdown [TRACE ntex_io::io] HTTP-TEST-SRV: 128353445462960 Io error None flags: Flags(IO_STOPPING | IO_STOPPING_FILTERS | WR_PAUSED) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Service shutdown is completed, stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Force close io stream object [TRACE ntex::web::ws] Ws handler is terminated: Ok(()) [TRACE ntex_io::tasks] WS-CLIENT: New 2 bytes available, wakeup dispatcher [TRACE ntex_io::tasks] WS-CLIENT: Tcp stream is disconnected [TRACE ntex_io::io] WS-CLIENT: 128353470800112 Io error None flags: Flags(BUF_R_READY | WR_PAUSED) [TRACE ntex_io::io] WS-CLIENT: 128353470800112 Dispatcher is not registered, flags: Flags(IO_STOPPED | IO_STOPPING | IO_STOPPING_FILTERS | BUF_R_READY | WR_PAUSED) [TRACE ntex_io::dispatcher] WS-CLIENT: Peer is gone, stopping dispatcher: None [TRACE ntex_io::ioref] WS-CLIENT: Stop timer [TRACE ntex_io::dispatcher] WS-CLIENT: Service shutdown is completed, stop [TRACE ntex_io::ioref] WS-CLIENT: Force close io stream object [TRACE ntex_io::tasks] WS-CLIENT: Write task is instructed to terminate [TRACE ntex_io::dispatcher] WS-CLIENT: Start keep-alive timer Seconds(5) [TRACE ntex_io::ioref] WS-CLIENT: Start timer Seconds(5) [TRACE ntex_io::tasks] HTTP-TEST-SRV: New 6 bytes available, wakeup dispatcher [TRACE ntex_io::io] HTTP-TEST-SRV: Initiate io shutdown Flags(DSP_STOP) [TRACE ntex_io::tasks] WS-CLIENT: New 2 bytes available, wakeup dispatcher [TRACE ntex_io::dispatcher] WS-CLIENT: Start keep-alive timer Seconds(5) [TRACE ntex_io::dispatcher] WS-CLIENT: Start keep-alive timer Seconds(5) [TRACE ntex_io::ioref] WS-CLIENT: Start timer Seconds(5) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Dispatcher is instructed to stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Stop timer [TRACE ntex_io::tasks] HTTP-TEST-SRV: Read io is closed, stop read task [TRACE ntex_io::tasks] HTTP-TEST-SRV: Write task is instructed to shutdown [TRACE ntex_io::io] HTTP-TEST-SRV: 128353445463408 Io error None flags: Flags(IO_STOPPING | IO_STOPPING_FILTERS | WR_PAUSED) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Service shutdown is completed, stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Force close io stream object [TRACE ntex::web::ws] Ws handler is terminated: Ok(()) [TRACE ntex_io::tasks] HTTP-TEST-SRV: New 6 bytes available, wakeup dispatcher [TRACE ntex_io::io] HTTP-TEST-SRV: Initiate io shutdown Flags(DSP_STOP) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Dispatcher is instructed to stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Stop timer [TRACE ntex_io::tasks] HTTP-TEST-SRV: Read io is closed, stop read task [TRACE ntex_io::tasks] HTTP-TEST-SRV: Write task is instructed to shutdown [TRACE ntex_io::io] HTTP-TEST-SRV: 128353445463632 Io error None flags: Flags(IO_STOPPING | IO_STOPPING_FILTERS | WR_PAUSED) [TRACE ntex_io::dispatcher] HTTP-TEST-SRV: Service shutdown is completed, stop [TRACE ntex_io::ioref] HTTP-TEST-SRV: Force close io stream object [TRACE ntex::web::ws] Ws handler is terminated: Ok(()) [TRACE ntex_io::tasks] WS-CLIENT: Tcp stream is disconnected [TRACE ntex_io::io] WS-CLIENT: 128353470800336 Io error None flags: Flags(WR_PAUSED) [TRACE ntex_io::tasks] WS-CLIENT: New 2 bytes available, wakeup dispatcher [TRACE ntex_io::tasks] WS-CLIENT: Tcp stream is disconnected [TRACE ntex_io::io] WS-CLIENT: 128353470800560 Io error None flags: Flags(BUF_R_READY | WR_PAUSED) [TRACE ntex_io::io] WS-CLIENT: 128353470800560 Dispatcher is not registered, flags: Flags(IO_STOPPED | IO_STOPPING | IO_STOPPING_FILTERS | BUF_R_READY | WR_PAUSED) [TRACE ntex_io::tasks] WS-CLIENT: Write task is instructed to terminate [TRACE ntex_io::dispatcher] WS-CLIENT: Peer is gone, stopping dispatcher: None [TRACE ntex_io::ioref] WS-CLIENT: Stop timer [TRACE ntex_io::dispatcher] WS-CLIENT: Service shutdown is completed, stop [TRACE ntex_io::ioref] WS-CLIENT: Force close io stream object [TRACE ntex_io::dispatcher] WS-CLIENT: Peer is gone, stopping dispatcher: None [TRACE ntex_io::ioref] WS-CLIENT: Stop timer [TRACE ntex_io::dispatcher] WS-CLIENT: Service shutdown is completed, stop [TRACE ntex_io::ioref] WS-CLIENT: Force close io stream object [TRACE ntex_io::tasks] WS-CLIENT: Write task is instructed to terminate [DEBUG ntex_rt::system] Stopping system with 0 code [ERROR ntex_server::wrk] Server is gone [INFO ntex_server::net::service] Worker service shutdown, 0 connections [INFO ntex_server::wrk] Worker WorkerId(0) has been stopped [INFO ntex_server::net::accept] Stopping accept loop [INFO ntex_server::net::accept] Stopping socket listener on 127.0.0.1:39259 [INFO ntex_server::net::accept] Accept loop has been stopped pthread lock: Invalid argument ```
5 条评论