@@ -17,9 +17,6 @@ package gnet
1717import (
1818 "context"
1919 "net"
20- "os"
21- "path/filepath"
22- "sync"
2320
2421 "golang.org/x/sync/errgroup"
2522
@@ -120,29 +117,6 @@ func (cli *Client) Stop() error {
120117 return err
121118}
122119
123- var (
124- mu sync.RWMutex
125- unixAddrDirs = make (map [string ]string )
126- )
127-
128- // unixAddr uses os.MkdirTemp to get a name that is unique.
129- func unixAddr (addr string ) string {
130- // Pass an empty pattern to get a directory name that is as short as possible.
131- // If we end up with a name longer than the sun_path field in the sockaddr_un
132- // struct, we won't be able to make the syscall to open the socket.
133- d , err := os .MkdirTemp ("" , "" )
134- if err != nil {
135- panic (err )
136- }
137-
138- tmpAddr := filepath .Join (d , addr )
139- mu .Lock ()
140- unixAddrDirs [tmpAddr ] = d
141- mu .Unlock ()
142-
143- return tmpAddr
144- }
145-
146120func (cli * Client ) Dial (network , addr string ) (Conn , error ) {
147121 return cli .DialContext (network , addr , nil )
148122}
@@ -152,18 +126,9 @@ func (cli *Client) DialContext(network, addr string, ctx any) (Conn, error) {
152126 c net.Conn
153127 err error
154128 )
155- if network == "unix" {
156- laddr , _ := net .ResolveUnixAddr (network , unixAddr (addr ))
157- raddr , _ := net .ResolveUnixAddr (network , addr )
158- c , err = net .DialUnix (network , laddr , raddr )
159- if err != nil {
160- return nil , err
161- }
162- } else {
163- c , err = net .Dial (network , addr )
164- if err != nil {
165- return nil , err
166- }
129+ c , err = net .Dial (network , addr )
130+ if err != nil {
131+ return nil , err
167132 }
168133 return cli .EnrollContext (c , ctx )
169134}
@@ -219,12 +184,6 @@ func (cli *Client) EnrollContext(nc net.Conn, ctx any) (gc Conn, err error) {
219184 n , err := nc .Read (buffer [:])
220185 if err != nil {
221186 el .ch <- & netErr {c , err }
222- mu .RLock ()
223- tmpDir := unixAddrDirs [nc .LocalAddr ().String ()]
224- mu .RUnlock ()
225- if err := os .RemoveAll (tmpDir ); err != nil {
226- logging .Errorf ("failed to remove temporary directory for unix local address: %v" , err )
227- }
228187 return
229188 }
230189 el .ch <- packTCPConn (c , buffer [:n ])
0 commit comments