|
|
@ -42,13 +42,13 @@ func NewServer(address string, factory MsgFactory, log *logging.Logger, handlers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
listener, err := net.ListenUnix("unix", &net.UnixAddr{address, "unix"})
|
|
|
|
listener, err := net.ListenUnix("unix", &net.UnixAddr{address, "unix"})
|
|
|
|
if err := setPassCred(listener); err != nil {
|
|
|
|
|
|
|
|
return nil, errors.New("Failed to set SO_PASSCRED on listening socket: " + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
md.close()
|
|
|
|
md.close()
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := setPassCred(listener); err != nil {
|
|
|
|
|
|
|
|
return nil, errors.New("Failed to set SO_PASSCRED on listening socket: " + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
done := make(chan bool)
|
|
|
|
done := make(chan bool)
|
|
|
|
idGen := newIdGen(done)
|
|
|
|
idGen := newIdGen(done)
|
|
|
|
return &MsgServer{
|
|
|
|
return &MsgServer{
|
|
|
@ -64,8 +64,6 @@ func (s *MsgServer) Run() error {
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
conn, err := s.listener.AcceptUnix()
|
|
|
|
conn, err := s.listener.AcceptUnix()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
s.disp.close()
|
|
|
|
|
|
|
|
s.listener.Close()
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := setPassCred(conn); err != nil {
|
|
|
|
if err := setPassCred(conn); err != nil {
|
|
|
@ -84,6 +82,12 @@ func (s *MsgServer) Run() error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *MsgServer) Close() error {
|
|
|
|
|
|
|
|
s.disp.close()
|
|
|
|
|
|
|
|
close(s.done)
|
|
|
|
|
|
|
|
return s.listener.Close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Connect(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgConn, error) {
|
|
|
|
func Connect(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgConn, error) {
|
|
|
|
md, err := createDispatcher(log, handlers...)
|
|
|
|
md, err := createDispatcher(log, handlers...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|