mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
On Posix: Don't shutdown (half) the connection from the client.
This triggered POLLHUP too early on Mac.
This commit is contained in:
@@ -124,12 +124,6 @@ Client::_send_cmds(const int argc, const char **argv)
|
|||||||
buf += n_sent;
|
buf += n_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the server know we're done writing.
|
|
||||||
if (shutdown(_fd, SHUT_WR) < 0) {
|
|
||||||
PX4_ERR("shutdown() failed: %s", strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -220,14 +220,15 @@ void
|
|||||||
cmd.resize(n + 1024);
|
cmd.resize(n + 1024);
|
||||||
ssize_t n_read = read(fd, &cmd[n], cmd.size() - n);
|
ssize_t n_read = read(fd, &cmd[n], cmd.size() - n);
|
||||||
|
|
||||||
if (n_read < 0) {
|
if (n_read <= 0) {
|
||||||
_cleanup(fd);
|
_cleanup(fd);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.resize(n + n_read);
|
cmd.resize(n + n_read);
|
||||||
|
|
||||||
if (n_read == 0) {
|
// Command ends in 0x00 (no tty) or 0x01 (tty).
|
||||||
|
if (!cmd.empty() && cmd.back() < 2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user