-
Notifications
You must be signed in to change notification settings - Fork 12
Code formating and refine #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
bfbbd1d
6fbd736
7721e0f
a80178b
508d4a7
3d0f1e9
6262199
94568ba
bdc9b10
b33c1f2
59471a5
5365d90
4cbf40b
eb084fe
f5778a4
ec65bb9
e988f5d
db7106b
5c7fa18
fb68b59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,9 @@ | |
| * along with rperf. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| use rperf::{args, client, server}; | ||
| use rperf::{args, client, server, BoxResult}; | ||
|
|
||
| fn main() { | ||
| fn main() -> BoxResult<()> { | ||
| use clap::Parser; | ||
| let args = args::Args::parse(); | ||
|
|
||
|
|
@@ -45,12 +45,8 @@ fn main() { | |
| .expect("unable to set SIGINT handler"); | ||
|
|
||
| log::debug!("beginning normal operation..."); | ||
| let service = server::serve(&args); | ||
| server::serve(&args)?; | ||
| exiting.join().expect("unable to join SIGINT handler thread"); | ||
| if service.is_err() { | ||
| log::error!("unable to run server: {}", service.unwrap_err()); | ||
| std::process::exit(4); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exit-code is important to help determine whether an environmental error has occurred. I must ask that it not be suppressed -- the changes here would replace it with |
||
| } | ||
| } else if args.client.is_some() { | ||
| log::debug!("registering SIGINT handler..."); | ||
| ctrlc2::set_handler(move || { | ||
|
|
@@ -65,15 +61,11 @@ fn main() { | |
| .expect("unable to set SIGINT handler"); | ||
|
|
||
| log::debug!("connecting to server..."); | ||
| let execution = client::execute(&args); | ||
| if execution.is_err() { | ||
| log::error!("unable to run client: {}", execution.unwrap_err()); | ||
| std::process::exit(4); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exit-code is also important. |
||
| } | ||
| client::execute(&args)?; | ||
| } else { | ||
| use clap::CommandFactory; | ||
| let mut cmd = args::Args::command(); | ||
| cmd.print_help().unwrap(); | ||
| std::process::exit(2); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this one, too. |
||
| } | ||
| Ok(()) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get what you're going for here, but this breaks compatibility with hostname-based resolution.
Not everything will, or should, be specified as an IP address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, specifically a hostname as defined in https://datatracker.ietf.org/doc/html/rfc952 or an IP address, v4 or v6, per https://datatracker.ietf.org/doc/html/rfc1123#page-13, but I'm perfectly content for it to just be a string and for the user to figure it out if they enter something nonsensical, rather than having the tool try to hold their hand on something basic like this.