Skip to content

Commit

Permalink
Update the if-condition of return type to ensure it will fail if rest (
Browse files Browse the repository at this point in the history
…#1416)

server is not running successfully.

Signed-off-by: ChenYing Kuo <[email protected]>
  • Loading branch information
evshary authored Sep 13, 2024
1 parent 5395f3c commit 53ad313
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
// http_port: 8000,
// /// The number of worker thread in TOKIO runtime (default: 2)
// /// The configuration only takes effect if running as a dynamic plugin, which can not reuse the current runtime.
// work_thread_num: 0,
// work_thread_num: 2,
// /// The number of blocking thread in TOKIO runtime (default: 50)
// /// The configuration only takes effect if running as a dynamic plugin, which can not reuse the current runtime.
// max_block_thread_num: 50,
Expand Down
4 changes: 3 additions & 1 deletion plugins/zenoh-plugin-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ impl Plugin for RestPlugin {
timeout(Duration::from_millis(1), TOKIO_RUNTIME.spawn(task)).await
});

if let Ok(Err(e)) = task {
// The spawn task (TOKIO_RUNTIME.spawn(task)) should not return immediately. The server should block inside.
// If it returns immediately (for example, address already in use), we can get the error inside Ok
if let Ok(Ok(Err(e))) = task {
bail!("REST server failed within 1ms: {e}")
}
Ok(Box::new(RunningPlugin(conf)))
Expand Down

0 comments on commit 53ad313

Please sign in to comment.