-
-
Notifications
You must be signed in to change notification settings - Fork 707
[client, android] Fix/notifier threading #3807
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
Conversation
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.
Pull Request Overview
This PR removes the Android-specific stub router, unifies server routing on all platforms, and refactors the peer notifier to safely publish the last known address, FQDN, and peer count to new listeners while filtering out dynamic/domain routes in the routemanager notifier.
- Drop
server_android.go
and lift!android
build tag so the same server logic runs on Android - In
notifier.go
, filter out dynamic/domain routes when setting initial client routes - In
peer/notifier.go
, add last-known address/FQDN state, restructure locking, and immediately notify new listeners without deadlocking
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
client/internal/routemanager/server_android.go | Removed Android stub that returned “not supported” error |
client/internal/routemanager/server.go | Removed //go:build !android so server logic applies on Android |
client/internal/routemanager/notifier/notifier.go | Added filter to exclude dynamic/domain routes from initial client routes |
client/internal/peer/notifier.go | Tracked last address/FQDN, refactored locks, and extracted notify logic |
Comments suppressed due to low confidence (2)
client/internal/peer/notifier.go:34
- [nitpick] Variable name
address
is ambiguous. Rename toipAddress
for clarity and to distinguish from FQDN.
address := n.lastIPAddress
client/internal/routemanager/notifier/notifier.go:36
- Filtering out dynamic/domain routes adds new behavior. Add unit tests covering both dynamic and static routes to verify they render in the initial list correctly.
if r.IsDynamic() {
notifyListener(listener, lastNotification) | ||
// run on go routine to avoid on Java layer to call go functions on same thread |
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.
State-change callbacks are now dispatched synchronously via notifyListener
, which may block the caller or violate threading expectations on the Java side. Consider wrapping these calls in a goroutine, similar to OnPeersListChanged
.
notifyListener(listener, lastNotification) | |
// run on go routine to avoid on Java layer to call go functions on same thread | |
// run on go routine to avoid on Java layer to call go functions on same thread | |
go notifyListener(listener, lastNotification) |
Copilot uses AI. Check for mistakes.
n.lastNumberOfPeers = numOfPeers | ||
n.serverStateLock.Unlock() |
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.
[nitpick] The manual lock/unlock patterns repeat across methods, making the code verbose. Consider extracting a helper or using scoped defer
blocks to simplify lock management.
n.lastNumberOfPeers = numOfPeers | |
n.serverStateLock.Unlock() | |
defer n.serverStateLock.Unlock() | |
n.lastNumberOfPeers = numOfPeers |
Copilot uses AI. Check for mistakes.
|
Describe your changes
Issue ticket number and link
Stack
Checklist