mirror of
https://github.com/wiggin77/mailrelay.git
synced 2025-08-18 10:59:43 +02:00
fix race
This commit is contained in:
6
Makefile
6
Makefile
@@ -25,6 +25,11 @@ build:
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
# Run tests with race condition detection
|
||||
.PHONY: test-race
|
||||
test-race:
|
||||
go test -race ./...
|
||||
|
||||
# Build for all supported architectures
|
||||
.PHONY: buildall
|
||||
buildall: clean
|
||||
@@ -78,6 +83,7 @@ help:
|
||||
@echo " build - Build for current architecture"
|
||||
@echo " buildall - Build for all supported architectures"
|
||||
@echo " test - Run tests"
|
||||
@echo " test-race - Run tests with race condition detection"
|
||||
@echo " check-style - Install golangci-lint and run code style checks"
|
||||
@echo " clean - Remove build artifacts"
|
||||
@echo " run - Build and run the application"
|
||||
|
@@ -165,10 +165,10 @@ func (s *MockSMTPServer) Reset() {
|
||||
}
|
||||
|
||||
func (s *MockSMTPServer) acceptConnections() {
|
||||
for s.running {
|
||||
for s.isRunning() {
|
||||
conn, err := s.listener.Accept()
|
||||
if err != nil {
|
||||
if s.running {
|
||||
if s.isRunning() {
|
||||
fmt.Printf("Accept error: %v\n", err)
|
||||
}
|
||||
continue
|
||||
@@ -178,6 +178,12 @@ func (s *MockSMTPServer) acceptConnections() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MockSMTPServer) isRunning() bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.running
|
||||
}
|
||||
|
||||
func (s *MockSMTPServer) handleConnection(conn net.Conn) {
|
||||
defer conn.Close()
|
||||
|
||||
|
Reference in New Issue
Block a user