mirror of
https://github.com/masterking32/MasterHttpRelayVPN.git
synced 2026-05-18 23:54:37 +03:00
Improve queue cleanup, batch fairness, and worker CPU efficiency
This commit is contained in:
@@ -29,8 +29,10 @@ type Client struct {
|
||||
|
||||
connMu sync.Mutex
|
||||
conns map[net.Conn]struct{}
|
||||
workCh chan struct{}
|
||||
|
||||
lastPollUnixMS atomic.Int64
|
||||
batchCursor atomic.Uint64
|
||||
}
|
||||
|
||||
func New(cfg config.Config, lg *logger.Logger) *Client {
|
||||
@@ -43,6 +45,7 @@ func New(cfg config.Config, lg *logger.Logger) *Client {
|
||||
socksConnections: NewSOCKSConnectionStore(),
|
||||
chunkPolicy: newChunkPolicy(cfg),
|
||||
conns: make(map[net.Conn]struct{}),
|
||||
workCh: make(chan struct{}, 1),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +121,13 @@ func (c *Client) closeAllConns() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) signalSendWork() {
|
||||
select {
|
||||
case c.workCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func generateClientSessionKey() string {
|
||||
now := time.Now().UTC().Format("20060102T150405.000000000Z")
|
||||
random := make([]byte, 16)
|
||||
|
||||
Reference in New Issue
Block a user