Archived
1
0

fix problems in varnish invalidation maybe

This commit is contained in:
Jeff Becker 2018-12-21 08:39:01 -05:00
parent 3b492579b8
commit ae9a96a35f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -13,6 +13,7 @@ type VarnishCache struct {
prefix string prefix string
handler *nullHandler handler *nullHandler
client *http.Client client *http.Client
transport *http.Transport
workers int workers int
threadsRegenChan chan ArticleEntry threadsRegenChan chan ArticleEntry
invalidateChan chan *url.URL invalidateChan chan *url.URL
@ -52,6 +53,7 @@ func (self *VarnishCache) doRequest(u *url.URL) {
} else { } else {
log.Println("varnish cache error", err) log.Println("varnish cache error", err)
} }
self.transport.CloseIdleConnections()
} }
func (self *VarnishCache) DeleteBoardMarkup(group string) { func (self *VarnishCache) DeleteBoardMarkup(group string) {
@ -178,8 +180,7 @@ func NewVarnishCache(varnish_url, bind_addr, prefix, webroot, name, translations
if err != nil { if err != nil {
log.Fatalf("failed to resolve %s for varnish cache: %s", bind_addr, err) log.Fatalf("failed to resolve %s for varnish cache: %s", bind_addr, err)
} }
cache.client = &http.Client{ cache.transport = &http.Transport{
Transport: &http.Transport{
Dial: func(network, addr string) (c net.Conn, err error) { Dial: func(network, addr string) (c net.Conn, err error) {
var remote_addr *net.TCPAddr var remote_addr *net.TCPAddr
remote_addr, err = net.ResolveTCPAddr(network, addr) remote_addr, err = net.ResolveTCPAddr(network, addr)
@ -188,8 +189,11 @@ func NewVarnishCache(varnish_url, bind_addr, prefix, webroot, name, translations
} }
return return
}, },
},
} }
cache.client = &http.Client{
Transport: cache.transport,
}
cache.prefix = "/" cache.prefix = "/"
cache.handler = &nullHandler{ cache.handler = &nullHandler{
prefix: prefix, prefix: prefix,