diff options
Diffstat (limited to 'forged/internal/incoming/lmtp/config.go')
-rw-r--r-- | forged/internal/incoming/lmtp/config.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/forged/internal/incoming/lmtp/config.go b/forged/internal/incoming/lmtp/config.go index e6db5a6..c622648 100644 --- a/forged/internal/incoming/lmtp/config.go +++ b/forged/internal/incoming/lmtp/config.go @@ -1,6 +1,7 @@ package lmtp import ( + "context" "fmt" "net" @@ -33,11 +34,20 @@ func New(config Config) (server *Server) { } } -func (server *Server) Run() error { +func (server *Server) Run(ctx context.Context) error { listener, _, err := misc.ListenUnixSocket(server.socket) if err != nil { return fmt.Errorf("listen unix socket for LMTP: %w", err) } + defer func() { + _ = listener.Close() + }() + + go func() { + <-ctx.Done() + _ = listener.Close() + // TODO: Log the error + }() for { conn, err := listener.Accept() |