kike: allow messages before protocol establishment
We can just queue them.
This commit is contained in:
parent
f36d66b0cb
commit
ced2a57cfc
13
kike.c
13
kike.c
@ -829,7 +829,7 @@ client_get_mode (struct client *self)
|
|||||||
static void
|
static void
|
||||||
client_send_str (struct client *c, const struct str *s)
|
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;
|
size_t old_sendq = c->write_buffer.len;
|
||||||
// TODO: kill the connection above some "SendQ" threshold (careful!)
|
// TODO: kill the connection above some "SendQ" threshold (careful!)
|
||||||
@ -933,15 +933,9 @@ client_kill (struct client *c, const char *reason)
|
|||||||
static void
|
static void
|
||||||
client_close_link (struct client *c, const char *reason)
|
client_close_link (struct client *c, const char *reason)
|
||||||
{
|
{
|
||||||
// Cannot push data to a client whose protocol we don't even know,
|
// Let's just cut the connection, the client can try again later.
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// We also want to avoid accidentally setting poller events before
|
// We also want to avoid accidentally setting poller events before
|
||||||
// address resolution has finished.
|
// address resolution has finished.
|
||||||
//
|
|
||||||
// Let's just cut the connection, the client can try again later.
|
|
||||||
if (!c->initialized)
|
if (!c->initialized)
|
||||||
{
|
{
|
||||||
client_kill (c, reason);
|
client_kill (c, reason);
|
||||||
@ -3365,6 +3359,7 @@ on_client_ready (const struct pollfd *pfd, void *user_data)
|
|||||||
static void
|
static void
|
||||||
client_update_poller (struct client *c, const struct pollfd *pfd)
|
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;
|
int new_events = POLLIN;
|
||||||
if (c->ssl)
|
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_rx_want_tx) new_events &= ~POLLIN;
|
||||||
if (c->ssl_tx_want_rx) new_events &= ~POLLOUT;
|
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;
|
new_events |= POLLOUT;
|
||||||
|
|
||||||
hard_assert (new_events != 0);
|
hard_assert (new_events != 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user