Skip to content

Commit ba230f4

Browse files
authored
Merge pull request #9 from sohonetlabs/PVT-889
PVT-889 - Fix control socket SIGPIPE crash on write to a closed client
2 parents 4a5a2a7 + 3d0341c commit ba230f4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/control_socket.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ static ssize_t write_all(fd_t fd, const void *buf, size_t count)
130130
size_t rest = count;
131131
ssize_t w = 0;
132132

133-
while (rest > 0 && ((fd > 2 && (w = send(fd, p, rest, MSG_NOSIGNAL)) > 0) ||
134-
(w = write(fd, p, rest)) > 0)) {
133+
while (rest > 0) {
134+
w = fd > 2 ? send(fd, p, rest, MSG_NOSIGNAL) : write(fd, p, rest);
135+
if (w <= 0) {
136+
break;
137+
}
135138
p += w;
136139
rest -= w;
137140
}

0 commit comments

Comments
 (0)