Fix goroutine leak.

Fixes #10
Tired coding is bad for you, mkay?
This commit is contained in:
xenolf 2015-10-18 17:27:59 +02:00
parent d322fc0c7e
commit 10b0192255

View file

@ -305,6 +305,9 @@ func (c *Client) requestCertificates(challenges []*authorizationResource) ([]Cer
} }
} }
close(resc)
close(errc)
return certs, nil return certs, nil
} }
@ -358,8 +361,11 @@ func (c *Client) requestCertificate(authz *authorizationResource, result chan Ce
if len(cert) > 0 { if len(cert) > 0 {
cerRes.CertStableURL = resp.Header.Get("Content-Location") cerRes.CertStableURL = resp.Header.Get("Content-Location")
cerRes.Certificate = pemEncode(derCertificateBytes(cert)) cerRes.Certificate = pemEncode(derCertificateBytes(cert))
logger().Printf("[%s] Server responded with a certificate.", authz.Domain)
result <- cerRes result <- cerRes
} else { return
}
// The certificate was granted but is not yet issued. // The certificate was granted but is not yet issued.
// Check retry-after and loop. // Check retry-after and loop.
ra := resp.Header.Get("Retry-After") ra := resp.Header.Get("Retry-After")
@ -370,8 +376,8 @@ func (c *Client) requestCertificate(authz *authorizationResource, result chan Ce
} }
logger().Printf("[%s] Server responded with status 202. Respecting retry-after of: %d", authz.Domain, retryAfter) logger().Printf("[%s] Server responded with status 202. Respecting retry-after of: %d", authz.Domain, retryAfter)
time.Sleep(time.Duration(retryAfter) * time.Millisecond) time.Sleep(time.Duration(retryAfter) * time.Second)
}
break break
default: default:
logger().Fatalf("[%s] The server returned an unexpected status code %d.", authz.Domain, resp.StatusCode) logger().Fatalf("[%s] The server returned an unexpected status code %d.", authz.Domain, resp.StatusCode)