8000 [full-ci] Fix panic while traversing the service list by 2403905 · Pull Request #11390 · owncloud/ocis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[full-ci] Fix panic while traversing the service list #11390

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

2403905
Copy link
Contributor
@2403905 2403905 commented Jun 2, 2025

Description

Fix panic while traversing the service list.

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@2403905 2403905 requested a review from jvillafanez June 2, 2025 14:46
@2403905 2403905 marked this pull request as ready for review June 2, 2025 14:47
@2403905 2403905 enabled auto-merge June 2, 2025 14:47
Copy link
Member
@jvillafanez jvillafanez left a comment

Choose a reason for hiding this comment

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

Using a RWMutex might be better, but I don't think we expect too much concurrency to be really useful. I mean, we probably need to deal with one goroutine for the startup and another one for the list command, so only 2 goroutines to handle.

@@ -486,6 +488,8 @@ func (s *Service) List(_ struct{}, reply *string) error {
table := tablewriter.NewWriter(tableString)
table.SetHeader([]string{"Service"})

s.mu.Lock()
defer s.mu.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

something to consider is to move the unlock right after the for so the mutex is locked the least amount of time. In this case it isn't a big deal because the function shouldn't take a lot of time to complete, so the mutex should be locked for a little time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -519,6 +523,8 @@ func trapShutdownCtx(s *Service, srv *http.Server, ctx context.Context) {
s.Log.Info().Msg("tcp listener shutdown")
}()

s.mu.Lock()
defer s.mu.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

better move the unlock after the for loop, otherwise we'll need to wait until all the services have shutdown of we reach the _defaultInterruptTimeoutDuration timeout; it will take too much time to unlock the mutex and it could block other goroutines for a long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
sonarqubecloud bot commented Jun 3, 2025

@2403905 2403905 merged commit afd3690 into owncloud:master Jun 3, 2025
4 checks passed
ownclouders pushed a commit that referenced this pull request Jun 3, 2025
[full-ci] Fix panic while traversing the service list
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.

Panic while traversing the service list
2 participants
0