Fix dead lock

dns-dead-lock
Fangliding 2025-08-25 13:16:51 +08:00
parent 33272a0499
commit f45ca197a2
No known key found for this signature in database
GPG Key ID: 67746ECEFA41C2B4
1 changed files with 1 additions and 12 deletions

View File

@ -171,6 +171,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
timer := signal.CancelAfterInactivity(ctx, cancel, h.timeout) timer := signal.CancelAfterInactivity(ctx, cancel, h.timeout)
request := func() error { request := func() error {
conn.dial()
defer conn.Close() defer conn.Close()
for { for {
@ -384,18 +385,6 @@ func (c *outboundConn) dial() error {
} }
func (c *outboundConn) Write(b []byte) (int, error) { func (c *outboundConn) Write(b []byte) (int, error) {
c.access.Lock()
if c.conn == nil {
if err := c.dial(); err != nil {
c.access.Unlock()
errors.LogWarningInner(context.Background(), err, "failed to dial outbound connection")
return len(b), nil
}
}
c.access.Unlock()
return c.conn.Write(b) return c.conn.Write(b)
} }