[PATCH][RFC] Remove syscall.Sendmsg dummy byte

149 views
Skip to first unread message

Brandon Philips

unread,
Sep 20, 2013, 4:50:29 PM9/20/13
to golan...@googlegroups.com, David Fisher
Hello-

tl;dr Go's Sendmsg always sends a "dummy byte" even when you are only
sending OOB data. This breaks a protocol I want to talk to:
systemd-journal. See attached patch for a "fix".

While working on go-systemd[1] David found that Go syscall.Sendmsg was
always sending one byte of data when we only wanted to send out of
band data (a file descriptor). The attached patch "fixes" the problem
for us but also breaks the tests.

This is the line of code in systemd-journal that rejects messages with
the dummy byte:
https://github.com/systemd/systemd/blob/master/src/journal/journald-server.c#L1238

Instead of fixing everything up I wanted to understand _why_ this
dummy byte is being sent first. The code seems to have been there
since the initial commit of the syscall_linux.go.

So, why was does this dummy byte exist? Are there other platforms that
require this byte?

If I fixup all of the tests and the poller is this patch mergeable?

Thank You,

Brandon

[1] https://github.com/coreos/go-systemd/blob/master/journal/send.go#L83
remove-recvmsg-dummy-byte.patch

Mikio Hara

unread,
Sep 20, 2013, 7:49:42 PM9/20/13
to Brandon Philips, golang-nuts, David Fisher
On Sat, Sep 21, 2013 at 5:50 AM, Brandon Philips <bra...@ifup.co> wrote:

> Instead of fixing everything up I wanted to understand _why_ this
> dummy byte is being sent first.

https://codereview.appspot.com/2331044#msg12
Hm, interesting.

Brandon Philips

unread,
Sep 20, 2013, 7:59:30 PM9/20/13
to golan...@googlegroups.com, ful...@gmail.com, David Fisher
Hello Albert-

Could you explain why the 1 byte dummy is needed? It seems you wrote the code :)

https://codereview.appspot.com/2331044/#ps28001

Thanks!

Brandon

Albert Strasheim

unread,
Sep 22, 2013, 7:36:04 PM9/22/13
to Brandon Philips, golang-nuts, David Fisher
Hello

Sorry, I was away for a bit.

On Sat, Sep 21, 2013 at 1:59 AM, Brandon Philips <bra...@ifup.co> wrote:
> Hello Albert-
> Could you explain why the 1 byte dummy is needed? It seems you wrote the code :)
> https://codereview.appspot.com/2331044/#ps28001

I'm having to dig into deep swap here. :-)

Initial discussion with agl on this topic:

https://groups.google.com/d/topic/golang-dev/Rkwgwug2OpI/discussion

The code review you linked has most of the followup discussion:

https://codereview.appspot.com/2331044/

which linked to:

http://svn.python.org/projects/python/branches/py3k/Modules/_multiprocessing/multiprocessing.c

which had the same dummy byte, to which rsc said:

"Yes, that's what everyone resorts to. Sigh."

So it seems there are some conditions under which it simply doesn't
work without the dummy byte. I'll need to write some tests to remember
exactly what they were. I'll report back once I have some time to
remember more. Hopefully tomorrow.

Regards

Albert

P.S. I love that Go, CoreOS and systemd are starting to play together.
Very exciting.
Reply all
Reply to author
Forward
0 new messages