Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Ignore SIGPIPE #195

@lovesegfault

Description

@lovesegfault

I've been using tower-grpc at work, and after writing a test for a server/client comm I found that it would fail sporadically with a broken pipe error:

Protocol(Error(Io, Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }))

Now, the test would work, the data seemed to go through, and everything was fine if not for that annoying broken pipe. I used strace to see what was going on, and found the problem area:

12638 1563904381.031034 writev(79, [{iov_base="\0\24\274\0\0\0\0\0\1", iov_len=9}, {iov_base="\0\0\0\24\267\n\264)\f\0\0\0\10\0\f\0\7\0\10\0\10\0\0\0\0\0\0\1\4\0\0\0"..., iov_len=5308}], 2) = 5317
12644 1563904381.031084 close(78)             = 0
12643 1563904381.031094 sched_yield()         = 0
12639 1563904381.031122 sched_yield()         = 0
12642 1563904381.031147 epoll_wait(63, [{EPOLLIN, {u32=4294967295, u64=18446744073709551615}}], 1024, -1) = 1
12649 1563904381.031181 epoll_wait(40, [], 1024, 0) = 0
12643 1563904381.031191 sched_yield()         = 0
12641 1563904381.031198 sched_yield()         = 0
12639 1563904381.031237 sched_yield()         = 0
12643 1563904381.031300 epoll_wait(57, [], 1024, 0) = 0
12641 1563904381.031324 epoll_wait(64, [], 1024, 0) = 0
12644 1563904381.031362 write(66, "\1", 1)    = 1
12638 1563904381.031392 writev(79, [{iov_base="\0\0\f\1\5\0\0\0\1@\210\232\312\310\262\0224\332\217\201\7", iov_len=21}], 1) = -1 EPIPE (Broken pipe)

I will also note the flags set when opening the socket:

socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 78

I think this happens because, on the client side, the HTTP client is moved into the future that is passed onto the Tokio executor, which then drops the connection once that is completed. The canonical GRPC implementation circumvents this issue, I think, by ignoring SIGPIPE which I believe we should so as well.

Have I identified the issue correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions