Skip to content

Commit

Permalink
TCP Proxy: use struct{} instead of bool
Browse files Browse the repository at this point in the history
  • Loading branch information
setaou committed Mar 25, 2024
1 parent 43f7b72 commit 30a127e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backends_processor/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ type MySQLCheck struct {
backoff_factor float64
status_chan chan *backend.Backend
ticker *misc.ExponentialBackoffTicker
stop_chan chan bool
stop_chan chan struct{}
running bool
db *sql.DB
check_replica bool
Expand All @@ -294,7 +294,7 @@ func NewMySQLCheck(backend *backend.Backend, dsn string, default_period time.Dur
max_period: max_period,
backoff_factor: backoff_factor,
status_chan: status_chan,
stop_chan: make(chan bool),
stop_chan: make(chan struct{}),
running: false,
check_replica: check_replica,
}
Expand Down Expand Up @@ -514,5 +514,5 @@ func (c *MySQLCheck) StopPolling() {

c.db.Close()
c.ticker.Stop()
c.stop_chan <- true
close(c.stop_chan)
}
6 changes: 3 additions & 3 deletions proxy/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (p *ProxyTCP) listen(address string, wg *sync.WaitGroup, ctx context.Contex
}()
}

func (p *ProxyTCP) pipe(input net.Conn, output net.Conn, done chan bool, input_timeout time.Duration, output_timeout time.Duration, counter *atomic.Uint64) {
func (p *ProxyTCP) pipe(input net.Conn, output net.Conn, done chan struct{}, input_timeout time.Duration, output_timeout time.Duration, counter *atomic.Uint64) {
// Error handler
defer func() {
if r := recover(); r != nil {
Expand Down Expand Up @@ -291,8 +291,8 @@ func (p *ProxyTCP) handle_connection(conn_front net.Conn) {
}

// Pipe the connections both ways
done_front_back := make(chan bool)
done_back_front := make(chan bool)
done_front_back := make(chan struct{})
done_back_front := make(chan struct{})
var bytes_in, bytes_out atomic.Uint64

go p.pipe(conn_front, conn_back, done_front_back, p.client_timeout, p.server_timeout, &bytes_in)
Expand Down

0 comments on commit 30a127e

Please sign in to comment.