Skip to content

Commit

Permalink
Fix: sharing app instances with different hostnames not working
Browse files Browse the repository at this point in the history
This fixes a problem where it fails to reuse the same instance of the app
when using multiple hostnames with different names (multiple symlinks pointing
to the same folder).

The bug was introduced in puma#270. The patch is based on adding the checksum in
all cases when a symlink is involved, not only when the names don't match. If not,
it can happen that it's not added if the name matches for the first execution, which
results in not finding the app instance later, resulting in an error "There is already
a server bound to..."

Fixes puma#280
  • Loading branch information
jorgemanrubia committed Jul 9, 2021
1 parent 41db297 commit bda9010
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dev/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,11 @@ func (a *AppPool) App(name string) (*App, error) {
destStat, err := os.Stat(destPath)
if err == nil {
destName := destStat.Name()
h := sha1.New()
h.Write([]byte(destPath))
canonicalName = fmt.Sprintf("%s-%.4x", destStat.Name(), h.Sum(nil))

if destName != name {
h := sha1.New()
h.Write([]byte(destPath))
canonicalName = fmt.Sprintf("%s-%.4x", destStat.Name(), h.Sum(nil))
aliasName = name
}
}
Expand Down

0 comments on commit bda9010

Please sign in to comment.