fix problems in varnish invalidation maybe
This commit is contained in:
parent
3b492579b8
commit
ae9a96a35f
@ -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,18 +180,20 @@ 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)
|
if err == nil {
|
||||||
if err == nil {
|
c, err = net.DialTCP(network, local_addr, remote_addr)
|
||||||
c, err = net.DialTCP(network, local_addr, remote_addr)
|
}
|
||||||
}
|
return
|
||||||
return
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
cache.client = &http.Client{
|
||||||
|
Transport: cache.transport,
|
||||||
|
}
|
||||||
|
|
||||||
cache.prefix = "/"
|
cache.prefix = "/"
|
||||||
cache.handler = &nullHandler{
|
cache.handler = &nullHandler{
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
|
Reference in New Issue
Block a user