-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClientContext (tcp) updates #5089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to compile with full debugging options. I'm seeing build failures due to variables you've done away with still setting in DEBUGV lines.
if (_pcb->snd_queuelen >= TCP_SND_QUEUELEN) { | ||
can_send = 0; | ||
} | ||
size_t will_send = (can_send < left) ? can_send : left; | ||
DEBUGV(":wr %d %d %d\r\n", will_send, left, _written); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug lines fail to compile due to them trying to dump variables that were just removed (left
)
// user data will not stay in place when data are sent but not acknowledged | ||
flags |= TCP_WRITE_FLAG_COPY; | ||
err_t err = tcp_write(_pcb, buf, next_chunk_size, flags); | ||
DEBUGV(":wrc %d %d %d\r\n", next_chunk_size, will_send, (int)err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will_send
undefined, too
Functionally, when compiled w/o debugging, this patch doesn't seem to cause any problems with BearSSL or axTLS in simple testing (bssl_validatiaon, https_request). |
Simple refactor to make WiFiClientSecureAxTLS use an external header to define its SSLContext, just as it does for several other classes. Fixes esp8266#3648
As part of the "clear connection configuration for reused objects" patch, a ::stop would reset the self-signed, trust anchors, etc. WiFiClient, unfortunately, calls ::stop as part of the connection process, so all of these settings were lost. Now only clear the connection settings on ::stop if we've already been connected. Also update the github public key which changed yet again. Fixes esp8266#5086
2423ad3
to
d06cac2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos on the constness!
@@ -35,7 +35,7 @@ class ClientContext | |||
{ | |||
public: | |||
ClientContext(tcp_pcb* pcb, discard_cb_t discard_cb, void* discard_cb_arg) : | |||
_pcb(pcb), _rx_buf(0), _rx_buf_offset(0), _discard_cb(discard_cb), _discard_cb_arg(discard_cb_arg), _refcnt(0), _next(0) | |||
_pcb(pcb), _rx_buf(0), _rx_buf_offset(0), _discard_cb(discard_cb), _discard_cb_arg(discard_cb_arg), _refcnt(0), _next(0), _sync(WiFiClient::getDefaultSync()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad idea, because it needlessly creates a circular dependency: ClientContext depends on WiFiClient, and WiFiClient depends on ClientContext. I suggest either factoring the sync into its own .h/.cpp, or pushing its declaration/definition into ClientContext.h/.cpp for reuse by WiFiClient class.
@@ -42,6 +42,8 @@ extern "C" | |||
#include "c_types.h" | |||
|
|||
uint16_t WiFiClient::_localPort = 0; | |||
bool WiFiClient::_defaultNoDelay = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest a big fat comment here about what the four combinations of nodelay and sync do, because I can't for the life of me keep them straight in my head.
@d-a-v, there's something weird in the tree and it's failing with the EthernetClient example builds. Very odd! Maybe it was using the ClientContext and something got broken? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as the SSL side goes, looks fine to me. Minor niggle on some C operator early-terminator, but would not -1 the patch for it. Thanks for the heads-up!
{ | ||
if (_client) | ||
_client->wait_until_sent(); | ||
return !_client || _client->wait_until_sent(maxWaitMs?: WIFICLIENT_MAX_FLUSH_WAIT_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the shorthand, but using the early-termination feature to avoid an if-then could be confusing
} | ||
WiFiClient::stop(); | ||
bool WiFiClientSecure::stop(unsigned int maxWaitMs) { | ||
bool ret = WiFiClient::stop(maxWaitMs); // calls our virtual flush() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see ::stop
calls ::flush
so we're OK there. Why I did _client->abort()
as well, I couldn't tell you. LGTM.
The build problem is the changes to the |
Added details for getters
client.setSync(bool)
(= "always flush" mode)slower when enabled but allocates less memory and data are always flushed
client.stop()
implicitely calls.flush()
(flush has a small timeout anyway)WiFiClient::setDefaultSync(bool)
/::setDefaultNoDelay(bool)
PuSH
flag from data packet