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:
|
test:
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|
||||||
|
# Run tests with race condition detection
|
||||||
|
.PHONY: test-race
|
||||||
|
test-race:
|
||||||
|
go test -race ./...
|
||||||
|
|
||||||
# Build for all supported architectures
|
# Build for all supported architectures
|
||||||
.PHONY: buildall
|
.PHONY: buildall
|
||||||
buildall: clean
|
buildall: clean
|
||||||
@@ -78,6 +83,7 @@ help:
|
|||||||
@echo " build - Build for current architecture"
|
@echo " build - Build for current architecture"
|
||||||
@echo " buildall - Build for all supported architectures"
|
@echo " buildall - Build for all supported architectures"
|
||||||
@echo " test - Run tests"
|
@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 " check-style - Install golangci-lint and run code style checks"
|
||||||
@echo " clean - Remove build artifacts"
|
@echo " clean - Remove build artifacts"
|
||||||
@echo " run - Build and run the application"
|
@echo " run - Build and run the application"
|
||||||
|
@@ -165,10 +165,10 @@ func (s *MockSMTPServer) Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MockSMTPServer) acceptConnections() {
|
func (s *MockSMTPServer) acceptConnections() {
|
||||||
for s.running {
|
for s.isRunning() {
|
||||||
conn, err := s.listener.Accept()
|
conn, err := s.listener.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if s.running {
|
if s.isRunning() {
|
||||||
fmt.Printf("Accept error: %v\n", err)
|
fmt.Printf("Accept error: %v\n", err)
|
||||||
}
|
}
|
||||||
continue
|
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) {
|
func (s *MockSMTPServer) handleConnection(conn net.Conn) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user