Skip to content

Commit f1cf23b

Browse files
committed
remove unused MutexQueue and unused sync.WaitGroup
1 parent 91e3dfc commit f1cf23b

File tree

1 file changed

+1
-46
lines changed

1 file changed

+1
-46
lines changed

pkg/transport/handler.go

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,9 @@ func HandleConnection(
139139
defer netRequest.CleanUp()
140140

141141
callCh := make(chan func(), 10)
142-
wg := sync.WaitGroup{}
143142
go func() {
144143
for f := range callCh {
145144
f()
146-
wg.Done()
147145
}
148146
}()
149147
for {
@@ -182,11 +180,8 @@ func HandleConnection(
182180
netHandler.HandleResponse(targetConn, conn, netRequest, isInBoundConn, true)
183181
closeConn(logger, targetConn)
184182
}
185-
wg.Add(1)
186183
callCh <- respRoutine
187184
}
188-
wg.Wait()
189-
close(callCh)
190185
} else {
191186
tcpDstAddr, err := net.ResolveTCPAddr("tcp", originalDstAddr)
192187
if err != nil {
@@ -229,44 +224,4 @@ func closeConn(logger *log.Logger, conn *net.TCPConn) {
229224
conn.CloseWrite()
230225
conn.Close()
231226
logger.Debug("Closed conn")
232-
}
233-
234-
type MutexQueue struct {
235-
muList *list.List
236-
mu sync.Mutex
237-
}
238-
239-
// MutexQueue implements mutex queue with FIFO support
240-
func NewMutexQueue() *MutexQueue {
241-
return &MutexQueue{
242-
muList: list.New(),
243-
}
244-
}
245-
246-
func (mq *MutexQueue) Lock() {
247-
mq.mu.Lock()
248-
if mq.muList.Len() == 0 {
249-
m := &sync.Mutex{}
250-
mq.muList.PushBack(m)
251-
m.Lock()
252-
mq.mu.Unlock()
253-
return
254-
}
255-
256-
tailMutex := mq.muList.Back().Value.(*sync.Mutex)
257-
m := &sync.Mutex{}
258-
mq.muList.PushBack(m)
259-
m.Lock()
260-
261-
mq.mu.Unlock()
262-
tailMutex.Lock()
263-
tailMutex.Unlock()
264-
}
265-
266-
func (mq *MutexQueue) Unlock() {
267-
mq.mu.Lock()
268-
frontMuEl := mq.muList.Front()
269-
frontMu := mq.muList.Remove(frontMuEl).(*sync.Mutex)
270-
frontMu.Unlock()
271-
mq.mu.Unlock()
272-
}
227+
}

0 commit comments

Comments
 (0)