mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-25 15:18:29 +02:00
Re-enable TCP nodelay for ESP32 (#2390)
This commit is contained in:
@@ -256,7 +256,7 @@ class LWIPRawImpl : public Socket {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*reinterpret_cast<int *>(optval) = tcp_nagle_disabled(pcb_);
|
||||
*reinterpret_cast<int *>(optval) = nodelay_;
|
||||
*optlen = 4;
|
||||
return 0;
|
||||
}
|
||||
@@ -285,11 +285,7 @@ class LWIPRawImpl : public Socket {
|
||||
return -1;
|
||||
}
|
||||
int val = *reinterpret_cast<const int *>(optval);
|
||||
if (val != 0) {
|
||||
tcp_nagle_disable(pcb_);
|
||||
} else {
|
||||
tcp_nagle_enable(pcb_);
|
||||
}
|
||||
nodelay_ = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -443,9 +439,11 @@ class LWIPRawImpl : public Socket {
|
||||
if (written == 0)
|
||||
// no need to output if nothing written
|
||||
return 0;
|
||||
int err = internal_output();
|
||||
if (err == -1)
|
||||
return -1;
|
||||
if (nodelay_) {
|
||||
int err = internal_output();
|
||||
if (err == -1)
|
||||
return -1;
|
||||
}
|
||||
return written;
|
||||
}
|
||||
ssize_t writev(const struct iovec *iov, int iovcnt) override {
|
||||
@@ -465,9 +463,11 @@ class LWIPRawImpl : public Socket {
|
||||
if (written == 0)
|
||||
// no need to output if nothing written
|
||||
return 0;
|
||||
int err = internal_output();
|
||||
if (err == -1)
|
||||
return -1;
|
||||
if (nodelay_) {
|
||||
int err = internal_output();
|
||||
if (err == -1)
|
||||
return -1;
|
||||
}
|
||||
return written;
|
||||
}
|
||||
int setblocking(bool blocking) override {
|
||||
@@ -549,6 +549,9 @@ class LWIPRawImpl : public Socket {
|
||||
bool rx_closed_ = false;
|
||||
pbuf *rx_buf_ = nullptr;
|
||||
size_t rx_buf_offset_ = 0;
|
||||
// don't use lwip nodelay flag, it sometimes causes reconnect
|
||||
// instead use it for determining whether to call lwip_output
|
||||
bool nodelay_ = false;
|
||||
};
|
||||
|
||||
std::unique_ptr<Socket> socket(int domain, int type, int protocol) {
|
||||
|
||||
Reference in New Issue
Block a user