1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

FSP: Check and exit the file 'writer' process if writes to stdout fails

This ensures that the 'writer' process will remove itself when the
main ELinks process for some reason decides to shutdown the connection.
Before the 'writer' process would complete it's task taking up unnecessary
system resources.

This is mostly an issue when fetching big files. Therefore only file
fetching is fixed. FIXME added about also checking return codes for write
associated with directory listing.

Reported-by: zas
This commit is contained in:
Jonas Fonseca 2006-02-02 16:29:20 +01:00
parent 135a79a3c3
commit 9090b68bd6

View File

@ -63,6 +63,11 @@ struct module fsp_protocol_module = struct_module(
);
/* FSP synchronous connection management: */
/* FIXME: Although it is probably not so much an issue, check if writes to
* stdout fails for directory listing like we do for file fetching. */
static void
fsp_error(unsigned char *error)
{
@ -214,7 +219,8 @@ do_fsp(struct connection *conn)
fclose(stderr);
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0)
fwrite(buf, 1, r, stdout);
if (safe_write(STDOUT_FILENO, buf, r) <= 0)
break;
fsp_fclose(file);
fsp_close_session(ses);
@ -222,6 +228,11 @@ do_fsp(struct connection *conn)
}
}
#undef READ_SIZE
/* FSP asynchronous connection management: */
static void
fsp_got_data(struct socket *socket, struct read_buffer *rb)
{
@ -284,8 +295,6 @@ fsp_got_header(struct socket *socket, struct read_buffer *rb)
read_from_socket(conn->data_socket, buf, S_CONN, fsp_got_data);
}
#undef READ_SIZE
void
fsp_protocol_handler(struct connection *conn)