-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved encoding error handling #297
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments/questions. Otherwise looks good to me.
} | ||
} | ||
|
||
// Emit emits the given signal on the message bus. The name parameter must be | ||
// formatted as "interface.member", e.g., "org.freedesktop.DBus.NameLost". | ||
func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) error { | ||
if !path.IsValid() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why are we dropping these checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they're redundant now as they're also done in msg.IsValid()
@@ -330,6 +335,7 @@ func (msg *Message) IsValid() error { | |||
return InvalidMessageError("missing signature") | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a spurious empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good @kolyshkin, adding linting was also on my bucket list
@@ -209,28 +210,23 @@ func (conn *Conn) handleCall(msg *Message) { | |||
} | |||
reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...)) | |||
|
|||
conn.sendMessageAndIfClosed(reply, nil) | |||
if err := reply.IsValid(); err != nil { | |||
fmt.Fprintf(os.Stderr, "dbus: dropping invalid reply to %s.%s on obj %s: %s\n", ifaceName, name, path, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of printing messages from libraries, but I don't have a better solution for this either.
Closes #295.
Logging from library code is not nice, but the best way to handle invalid reply messages IMO in a compatible way since there's not really a mechanism to make this known to application code.