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

Added some comments, and began hacking better close conditions and actions.

Rev: src/channel.c:1.19
Rev: src/client.c:1.41
Rev: src/server.c:1.31
parent d219d2b6
......@@ -167,10 +167,13 @@ struct channel_table *make_channel_table(void)
};
/* Returns -1 if allocation fails */
/* NOTE: This function returns locally chosen channel numbers, which
* are always small integers. So there's no problem fitting them in
* a signed int. */
int alloc_channel(struct channel_table *table)
{
/* FIXME: Use int here? */
UINT32 i;
for(i = table->next_channel; i < table->used_channels; i++)
{
if (!table->channels[i])
......@@ -181,6 +184,7 @@ int alloc_channel(struct channel_table *table)
}
if (i == table->max_channels)
return -1;
if (i == table->allocated_channels)
{
int new_size = table->allocated_channels * 2;
......@@ -210,6 +214,8 @@ void dealloc_channel(struct channel_table *table, int i)
table->next_channel = i;
}
/* Returns -1 if no channel number can be allocated. See also the note
* for alloc_channel(). */
int register_channel(struct channel_table *table, struct ssh_channel *channel)
{
int n = alloc_channel(table);
......@@ -703,6 +709,9 @@ static int do_channel_eof(struct packet_handler *c,
else
/* FIXME: What is a reasonable default behaviour?
* Closing the channel may be the right thing to do. */
if (! (channel->flags & CHANNEL_SENT_CLOSE))
res |= channel_close(channel);
#if 0
if (!LSH_CLOSEDP(res)
&& ! (channel->flags & CHANNEL_SENT_CLOSE)
&& (channel->flags & CHANNEL_SENT_EOF))
......@@ -712,7 +721,7 @@ static int do_channel_eof(struct packet_handler *c,
res |= channel_close(channel);
}
#endif
return channel_process_status(closure->table, channel_number,
res);
......
......@@ -370,6 +370,13 @@ static int do_exit_status(struct channel_request *c,
ALIST_SET(channel->request_types, ATOM_EXIT_STATUS, NULL);;
ALIST_SET(channel->request_types, ATOM_EXIT_SIGNAL, NULL);;
/* Sent EOF, if we haven't done that already. */
/* FIXME: Make this behaviour configurable, there may be some
* child process alive that we could talk to. */
if (!(channel->flags && CHANNEL_SENT_EOF))
return channel_eof(channel);
return LSH_OK | LSH_GOON;
}
......
......@@ -252,6 +252,7 @@ make_server_callback(struct io_backend *b,
static int server_die(struct close_callback *closure, int reason)
{
/* FIXME: If any processes are running, they should be killed now. */
verbose("Connection died, for reason %d.\n", reason);
if (reason != CLOSE_EOF)
werror("Connection died.\n");
......@@ -279,7 +280,8 @@ struct close_callback *make_server_close_handler(void)
; Non-zero if a shell or command has been started.
(running simple int)
; FIXME: We need the pid as well, to be able to kill
; the process if the channel or connection is closed.
; Child process's stdio
(in object io_fd)
(out object io_fd)
......@@ -505,6 +507,7 @@ static void do_exit_shell(struct exit_callback *c, int signaled,
}
#endif
/* FIXME: We shouldn't close until we have both sent and recieved eof. */
channel->flags |= CHANNEL_CLOSE_AT_EOF;
if (!(channel->flags & CHANNEL_SENT_CLOSE))
......
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