diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5srvPipegram.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvPipegram.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvPipegram.go b/src/hub/src/spreadspace.org/sfive/s5srvPipegram.go index b2807ed..65ff0e0 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvPipegram.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvPipegram.go @@ -40,12 +40,11 @@ import ( ) const ( - PipegramMessageSizeLimit = 1024 * 1024 // TODO: is this really needed? + PipegramMessageSizeLimit = 1024 * 1024 ) func (srv *Server) pipegramRun() { buffer := make([]byte, PipegramMessageSizeLimit) - for { n, _, err := srv.interfaces.pipegram.ReadFrom(buffer) if err != nil { @@ -70,7 +69,6 @@ func (srv *Server) pipegramRun() { } func (srv *Server) pipegramStop(ctx context.Context) (err error) { - // TODO: this is a race condition between a call to pipegramRun and pipegramStop... if srv.interfaces.pipegram == nil { return nil } @@ -85,8 +83,13 @@ func (srv *Server) ServePipegram(cfg PipegramInterfaceConfig) (err error) { } s5l.Printf("srv|pgram: listening on '%s'", cfg.ListenPath) - defer s5l.Println("srv|pgram: interface stopped") - srv.pipegramRun() + srv.wgInterfaces.Add(1) + go func() { + defer srv.wgInterfaces.Done() + defer s5l.Println("srv|pgram: interface stopped listening") + + srv.pipegramRun() + }() return } |