Commit b9449f73 authored by Niels Möller's avatar Niels Möller
Browse files

(transport_connection_kill): Cancel

oop_timer_retry.
(transport_stop_read): Likewise.
(oop_timer_retry): Assert that the connection is alive.

Rev: src/transport.c:1.13
parent 48d788ea
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
/* Time to wait for write buffer to drain after disconnect */ /* Time to wait for write buffer to drain after disconnect */
#define TRANSPORT_TIMEOUT_CLOSE (5 * 60) #define TRANSPORT_TIMEOUT_CLOSE (5 * 60)
/* Forward declaration. */
static void *
oop_timer_retry(oop_source *oop, struct timeval tv, void *state);
void void
init_transport_connection(struct transport_connection *self, init_transport_connection(struct transport_connection *self,
void (*kill)(struct resource *s), void (*kill)(struct resource *s),
...@@ -139,6 +143,9 @@ transport_connection_kill(struct transport_connection *connection) ...@@ -139,6 +143,9 @@ transport_connection_kill(struct transport_connection *connection)
connection->expire = NULL; connection->expire = NULL;
} }
global_oop_source->cancel_time(global_oop_source,
OOP_TIME_NOW, oop_timer_retry, connection);
io_close_fd(connection->ssh_input); io_close_fd(connection->ssh_input);
if (connection->ssh_output != connection->ssh_input) if (connection->ssh_output != connection->ssh_input)
...@@ -441,8 +448,13 @@ oop_timer_retry(oop_source *oop UNUSED, ...@@ -441,8 +448,13 @@ oop_timer_retry(oop_source *oop UNUSED,
struct timeval tv UNUSED, void *state) struct timeval tv UNUSED, void *state)
{ {
CAST_SUBTYPE(transport_connection, connection, (struct lsh_object *) state); CAST_SUBTYPE(transport_connection, connection, (struct lsh_object *) state);
uint32_t length = connection->retry_length; uint32_t length;
uint32_t seqno = connection->retry_seqno; uint32_t seqno;
assert(connection->super.alive);
length = connection->retry_length;
seqno = connection->retry_seqno;
assert(length); assert(length);
...@@ -516,6 +528,9 @@ transport_start_read(struct transport_connection *connection) ...@@ -516,6 +528,9 @@ transport_start_read(struct transport_connection *connection)
if (connection->retry_length) if (connection->retry_length)
/* Arrange to have the packet handler called from the main /* Arrange to have the packet handler called from the main
event loop. */ event loop. */
/* Note: To protect connection from gc, it is essential that
the timer is cancelled when the connection is killed.
FIXME: Use io_callout instead? */
global_oop_source->on_time(global_oop_source, global_oop_source->on_time(global_oop_source,
OOP_TIME_NOW, oop_timer_retry, connection); OOP_TIME_NOW, oop_timer_retry, connection);
else else
...@@ -528,6 +543,8 @@ void ...@@ -528,6 +543,8 @@ void
transport_stop_read(struct transport_connection *connection) transport_stop_read(struct transport_connection *connection)
{ {
connection->read_active = 0; connection->read_active = 0;
global_oop_source->cancel_time(global_oop_source,
OOP_TIME_NOW, oop_timer_retry, connection);
global_oop_source->cancel_fd(global_oop_source, global_oop_source->cancel_fd(global_oop_source,
connection->ssh_input, OOP_READ); connection->ssh_input, OOP_READ);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment