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

close_callbacks now get a reason as argument.

Rev: src/client.c:1.21
Rev: src/client.h:1.10
Rev: src/server.c:1.14
Rev: src/server.h:1.7
parent 14f8ea85
...@@ -191,15 +191,17 @@ make_client_callback(struct io_backend *b, ...@@ -191,15 +191,17 @@ make_client_callback(struct io_backend *b,
return &connected->super; return &connected->super;
} }
static int client_die(struct callback *closure) static int client_die(struct close_callback *closure, int reason)
{ {
verbose("Connection died, for reason %d.\n", reason);
if (reason != CLOSE_EOF)
werror("Connection died.\n"); werror("Connection died.\n");
exit(1); exit(1);
} }
struct callback *make_client_close_handler(void) struct close_callback *make_client_close_handler(void)
{ {
struct callback *c = xalloc(sizeof(struct callback)); struct close_callback *c = xalloc(sizeof(struct close_callback));
c->f = client_die; c->f = client_die;
......
...@@ -38,6 +38,6 @@ make_client_callback(struct io_backend *b, ...@@ -38,6 +38,6 @@ make_client_callback(struct io_backend *b,
struct packet_handler *kexinit_handler); struct packet_handler *kexinit_handler);
struct read_handler *make_client_read_line(struct ssh_connection *c); struct read_handler *make_client_read_line(struct ssh_connection *c);
struct callback *make_client_close_handler(void); struct close_callback *make_client_close_handler(void);
#endif /* LSH_CLIENT_H_INCLUDED */ #endif /* LSH_CLIENT_H_INCLUDED */
...@@ -182,16 +182,18 @@ make_server_callback(struct io_backend *b, ...@@ -182,16 +182,18 @@ make_server_callback(struct io_backend *b,
return &connected->super; return &connected->super;
} }
static int server_die(struct callback *closure) static int server_die(struct close_callback *closure, int reason)
{ {
verbose("Connection died, for reason %d.\n", reason);
if (reason != CLOSE_EOF)
werror("Connection died.\n"); werror("Connection died.\n");
/* FIXME: Cleanup properly. */
return 0; /* Ignored */ return 0; /* Ignored */
} }
struct callback *make_server_close_handler(void) struct close_callback *make_server_close_handler(void)
{ {
struct callback *c = xalloc(sizeof(struct callback)); struct close_callback *c = xalloc(sizeof(struct close_callback));
c->f = server_die; c->f = server_die;
......
...@@ -40,6 +40,6 @@ make_server_callback(struct io_backend *b, ...@@ -40,6 +40,6 @@ make_server_callback(struct io_backend *b,
struct packet_handler *kexinit_handler); struct packet_handler *kexinit_handler);
struct read_handler *make_server_read_line(struct ssh_connection *c); struct read_handler *make_server_read_line(struct ssh_connection *c);
struct callback *make_server_close_handler(void); struct close_callback *make_server_close_handler(void);
#endif /* LSH_SERVER_H_INCLUDED */ #endif /* LSH_SERVER_H_INCLUDED */
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