Skip to content
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

feat: play nice with aw-qt #60

Merged
merged 1 commit into from
Jan 20, 2025
Merged

Conversation

0xbrayo
Copy link
Member

@0xbrayo 0xbrayo commented Jan 20, 2025

Important

Adds port availability check in lib.rs to prevent server launch on occupied ports.

  • Behavior:
    • Adds is_port_available() function to check if a port is free in lib.rs.
    • In run(), checks port availability before launching the server and panics if the port is in use.
  • Functions:
    • New function is_port_available() added to lib.rs to determine port status using TcpListener.
  • Misc:
    • Imports SocketAddr and TcpListener in lib.rs for port checking functionality.

This description was created by Ellipsis for 04bfe39. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 04bfe39 in 1 minute and 51 seconds

More details
  • Looked at 49 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src-tauri/src/lib.rs:88
  • Draft comment:
    The TcpListener in is_port_available is not closed after checking, which might cause the port to remain occupied temporarily. Consider explicitly dropping the listener to ensure the port is released immediately.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment shows a misunderstanding of Rust's ownership and RAII principles. When the TcpListener goes out of scope at the end of the function, Rust will automatically drop it and release the port. There's no need for explicit cleanup. The function is correctly implemented and follows Rust idioms.
    Could there be edge cases where the port remains in a weird state between the bind and the drop? Could there be platform-specific issues I'm not considering?
    No, Rust's drop semantics are reliable across platforms, and TcpListener's Drop implementation is specifically designed to properly clean up the socket. The time between bind and drop is negligible.
    The comment should be deleted as it suggests unnecessary changes based on a misunderstanding of Rust's RAII guarantees.

Workflow ID: wflow_bhNVjb67tjHz7mKN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@0xbrayo
Copy link
Member Author

0xbrayo commented Jan 20, 2025

#17

@0xbrayo 0xbrayo merged commit 9b91b01 into ActivityWatch:master Jan 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant