|
|
@ -31,6 +31,7 @@ type MsgConn struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type MsgServer struct {
|
|
|
|
type MsgServer struct {
|
|
|
|
|
|
|
|
isClosed bool
|
|
|
|
log *logging.Logger
|
|
|
|
log *logging.Logger
|
|
|
|
disp *msgDispatcher
|
|
|
|
disp *msgDispatcher
|
|
|
|
factory MsgFactory
|
|
|
|
factory MsgFactory
|
|
|
@ -66,9 +67,12 @@ func NewServer(address string, factory MsgFactory, log *logging.Logger, handlers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *MsgServer) Run() error {
|
|
|
|
func (s *MsgServer) Run() error {
|
|
|
|
for {
|
|
|
|
for !s.isClosed {
|
|
|
|
conn, err := s.listener.AcceptUnix()
|
|
|
|
conn, err := s.listener.AcceptUnix()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
if s.isClosed {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := setPassCred(conn); err != nil {
|
|
|
|
if err := setPassCred(conn); err != nil {
|
|
|
@ -90,6 +94,10 @@ func (s *MsgServer) Run() error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *MsgServer) Close() error {
|
|
|
|
func (s *MsgServer) Close() error {
|
|
|
|
|
|
|
|
if s.isClosed {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
s.isClosed = true
|
|
|
|
s.disp.close()
|
|
|
|
s.disp.close()
|
|
|
|
close(s.done)
|
|
|
|
close(s.done)
|
|
|
|
return s.listener.Close()
|
|
|
|
return s.listener.Close()
|
|
|
|