diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-16 04:18:21 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-16 06:30:08 +0100 |
commit | ced2a57cfcf8f1ed45f93bc74a876a5eb2e9d0b3 (patch) | |
tree | 1c79bea751f03fda0fae2f02a9584492154bccd8 /kike.c | |
parent | f36d66b0cb3a11341dec25f6b205bfe86c903360 (diff) | |
download | xK-ced2a57cfcf8f1ed45f93bc74a876a5eb2e9d0b3.tar.gz xK-ced2a57cfcf8f1ed45f93bc74a876a5eb2e9d0b3.tar.xz xK-ced2a57cfcf8f1ed45f93bc74a876a5eb2e9d0b3.zip |
kike: allow messages before protocol establishment
We can just queue them.
Diffstat (limited to 'kike.c')
-rw-r--r-- | kike.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -829,7 +829,7 @@ client_get_mode (struct client *self) static void client_send_str (struct client *c, const struct str *s) { - hard_assert (c->initialized && !c->closing_link); + hard_assert (!c->closing_link); size_t old_sendq = c->write_buffer.len; // TODO: kill the connection above some "SendQ" threshold (careful!) @@ -933,15 +933,9 @@ client_kill (struct client *c, const char *reason) static void client_close_link (struct client *c, const char *reason) { - // Cannot push data to a client whose protocol we don't even know, - // at least not with current code (client_send_str(), on_client_ready()), - // which could possibly be solved by client_update_poller() not setting - // POLLOUT when the protocol hasn't been initialized yet. - // + // Let's just cut the connection, the client can try again later. // We also want to avoid accidentally setting poller events before // address resolution has finished. - // - // Let's just cut the connection, the client can try again later. if (!c->initialized) { client_kill (c, reason); @@ -3365,6 +3359,7 @@ on_client_ready (const struct pollfd *pfd, void *user_data) static void client_update_poller (struct client *c, const struct pollfd *pfd) { + // We must not poll for writing when the connection hasn't been initialized int new_events = POLLIN; if (c->ssl) { @@ -3375,7 +3370,7 @@ client_update_poller (struct client *c, const struct pollfd *pfd) if (c->ssl_rx_want_tx) new_events &= ~POLLIN; if (c->ssl_tx_want_rx) new_events &= ~POLLOUT; } - else if (c->write_buffer.len) + else if (c->initialized && c->write_buffer.len) new_events |= POLLOUT; hard_assert (new_events != 0); |