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

* src/io_commands.c (listen_with_callback): Redefined using

DEFINE_COMMAND3.

Rev: src/io_commands.c:1.42
Rev: src/io_commands.h:1.18
parent b831cb66
......@@ -165,61 +165,24 @@ do_listen(struct io_backend *backend,
* Suitable for handling forwarding requests. NOTE: The calling
* function has to do all remembering of the fd:s. */
/* GABA:
(class
(name listen_with_callback)
(super command)
(vars
(callback object command)
(backend object io_backend)))
*/
static void
do_listen_with_callback(struct command *s,
struct lsh_object *x,
struct command_continuation *c,
struct exception_handler *e)
DEFINE_COMMAND3(listen_with_callback)
(struct lsh_object *a1,
struct lsh_object *a2,
struct lsh_object *a3,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(listen_with_callback, self, s);
CAST(address_info, address, x);
CAST_SUBTYPE(command, callback, a1);
CAST(io_backend, backend, a2);
CAST(address_info, address, a3);
/* No dns lookups */
do_listen(self->backend, address,
do_listen(backend, address,
c,
make_apply(self->callback,
make_apply(callback,
&discard_continuation, e), e);
}
struct command *
make_listen_with_callback(struct command *callback,
struct io_backend *backend)
{
NEW(listen_with_callback, self);
self->callback = callback;
self->backend = backend;
self->super.call = do_listen_with_callback;
return &self->super;
}
static struct lsh_object *
collect_listen_callback(struct collect_info_2 *info,
struct lsh_object *a,
struct lsh_object *b)
{
CAST_SUBTYPE(command, callback, a);
CAST(io_backend, backend, b);
assert(!info->next);
return &make_listen_with_callback(callback, backend)->super;
}
static struct collect_info_2 collect_info_listen_callback_2 =
STATIC_COLLECT_2_FINAL(collect_listen_callback);
struct collect_info_1 listen_with_callback =
STATIC_COLLECT_1(&collect_info_listen_callback_2);
/* GABA:
(class
......
......@@ -76,8 +76,8 @@ struct command *
make_listen_with_callback(struct command *callback,
struct io_backend *backend);
extern struct collect_info_1 listen_with_callback;
#define LISTEN_CALLBACK (&listen_with_callback.super.super.super)
extern struct command_3 listen_with_callback;
#define LISTEN_CALLBACK (&listen_with_callback.super.super)
struct command *
make_connect_port(struct io_backend *backend,
......
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