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

(gateway_make_connection): New argument,

a resource to be adopted by the connection.
(gateway_init): Likewise.
(gateway_accept): Pass a NULL-resource to gateway_make_connection.

Rev: src/gateway_commands.c:1.24
Rev: src/gateway_commands.h:1.6
parent 09249e15
......@@ -196,6 +196,7 @@ make_read_gateway(struct abstract_write *handler,
static struct ssh_connection *
gateway_make_connection(struct listen_value *lv,
struct resource *resource,
struct exception_handler *e)
/* NOTE: lv->peer is usually NULL here. */
......@@ -204,6 +205,10 @@ gateway_make_connection(struct listen_value *lv,
lv->peer, lv->local, "gateway",
make_exc_finish_read_handler(lv->fd, e, HANDLER_CONTEXT));
/* Adopt resources associated with the connection. */
if (resource)
remember_resource(connection->resources, resource);
......@@ -231,15 +236,17 @@ gateway_make_connection(struct listen_value *lv,
return connection;
(struct command *s UNUSED,
struct lsh_object *a,
(struct command_2 *s UNUSED,
struct lsh_object *a1,
struct lsh_object *a2,
struct command_continuation *c,
struct exception_handler *e)
CAST(listen_value, lv, a);
CAST_SUBTYPE(resource, resource, a1);
CAST(listen_value, lv, a2);
COMMAND_RETURN(c, gateway_make_connection(lv, e));
COMMAND_RETURN(c, gateway_make_connection(lv, resource, e));
......@@ -254,7 +261,7 @@ DEFINE_COMMAND2(gateway_accept)
CAST(ssh_connection, connection, a1);
CAST(listen_value, lv, a2);
struct ssh_connection *gateway = gateway_make_connection(lv, e);
struct ssh_connection *gateway = gateway_make_connection(lv, NULL, e);
/* Kill gateway connection if the main connection goes down. */
remember_resource(connection->resources, &lv->fd->super);
......@@ -26,8 +26,8 @@
#include "io.h"
extern struct command gateway_init;
#define GATEWAY_INIT (&gateway_init.super)
extern struct command_2 gateway_init;
#define GATEWAY_INIT (&gateway_init.super.super)
extern struct command_2 gateway_accept;
#define GATEWAY_ACCEPT (&gateway_accept.super.super)
Supports Markdown
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