Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Fix leaky socket #8

Merged
merged 5 commits into from
Jun 23, 2017
Merged

Fix leaky socket #8

merged 5 commits into from
Jun 23, 2017

Conversation

murphybytes
Copy link
Contributor

This PR changes the usage http.Client of the updater so that all web requests use the same connection. Also a change was made that will make sure that backed up tuf repo files will be deleted after we are done with them.

Copy link
Contributor

@groob groob left a comment

Choose a reason for hiding this comment

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

@murphybytes I read through the PR and think we should make the http.Client a field on Settings.

This way, the user can provide a client they're already using and you can create a client if the one is settings is nil.

tuf/tuf.go Outdated
@@ -46,31 +46,56 @@ type Settings struct {
TargetName targetNameType
}

type Monitor interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs documentation, but I think this interface is a bit too much. Just export the struct.

tuf/tuf.go Outdated
client: &http.Client{
// New instantiatest and monitor which is used to detect and manage changes to
// the TUF repository.
func New(settings *Settings) *Monitor {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is better, but is there still a reason to have the monitor struct if it only holds the Settings struct?

		stagingPath, err := tuf.GetStagedPath(&u.settings)

This is the previous API and it can still work now as a function instead of a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this should be changed, but perhaps for another reason than you think. I'm passing a pointer to the Settings object to the loop goroutine so we could have concurrent access problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

The client should be safe for concurrent use.

Copy link
Contributor

@groob groob left a comment

Choose a reason for hiding this comment

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

LGTM now

@murphybytes murphybytes merged commit 44f5d5f into kolide:master Jun 23, 2017
@murphybytes murphybytes deleted the fixes branch June 23, 2017 21:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants