From bfb034c953b92228f681321728ba412c0b7fe70b Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 15 Jun 2008 14:17:44 +0300 Subject: [PATCH] Revert "copiousoutput: cleanup after copiousoutput handling. Temporary files should" I am reverting all copiousoutput support because of bug 917. This reverts commit 4dc4ea47f2d46490623305d79f46b4d8bdf670fc. Conflicts: src/network/connection.h: After the original commit, the declaration of copiousoutput_data had been changed to use the LIST_OF macro. Also, connection.cgi had been added next to the connection.popen member added by the original commit. src/session/download.c: After the original commit, the definition of copiousoutput_data had been changed to use the INIT_LIST_OF macro. --- src/network/connection.c | 21 --------------------- src/network/connection.h | 11 ----------- src/protocol/file/file.c | 2 -- src/session/download.c | 27 ++++++--------------------- 4 files changed, 6 insertions(+), 55 deletions(-) diff --git a/src/network/connection.c b/src/network/connection.c index f991a0fd0..3c1da9ada 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -4,7 +4,6 @@ #include "config.h" #endif -#include #include #include #ifdef HAVE_UNISTD_H @@ -384,25 +383,6 @@ shutdown_connection_stream(struct connection *conn) conn->stream_pipes[0] = conn->stream_pipes[1] = -1; } -static void -close_popen(int fd) -{ - struct popen_data *pop; - - foreach (pop, copiousoutput_data) { - if (pop->fd == fd) { - del_from_list(pop); - pclose(pop->stream); - if (pop->filename) { - unlink(pop->filename); - mem_free(pop->filename); - } - mem_free(pop); - break; - } - } -} - static void free_connection_data(struct connection *conn) { @@ -423,7 +403,6 @@ free_connection_data(struct connection *conn) if (conn->done) conn->done(conn); - if (conn->popen) close_popen(conn->socket->fd); done_socket(conn->socket); done_socket(conn->data_socket); diff --git a/src/network/connection.h b/src/network/connection.h index 311bbaaf7..f5b56c602 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -57,7 +57,6 @@ struct connection { unsigned int running:1; unsigned int unrestartable:1; unsigned int detached:1; - unsigned int popen:1; unsigned int cgi:1; /* Each document is downloaded with some priority. When downloading a @@ -75,16 +74,6 @@ struct connection { void *info; }; -struct popen_data { - LIST_HEAD(struct popen_data); - - int fd; - FILE *stream; - unsigned char *filename; -}; - -extern LIST_OF(struct popen_data) copiousoutput_data; - int register_check_queue(void); int get_connections_count(void); diff --git a/src/protocol/file/file.c b/src/protocol/file/file.c index 3a7f582d4..e6fe419e0 100644 --- a/src/protocol/file/file.c +++ b/src/protocol/file/file.c @@ -215,7 +215,6 @@ read_special(struct connection *conn, int fd) return; } conn->socket->fd = fd; - conn->popen = 1; rb = alloc_read_buffer(conn->socket); if (!rb) { abort_connection(conn, S_OUT_OF_MEM); @@ -225,7 +224,6 @@ read_special(struct connection *conn, int fd) rb->length = 45; rb->freespace -= 45; - conn->unrestartable = 1; conn->socket->state = SOCKET_END_ONCLOSE; read_from_socket(conn->socket, rb, S_SENT, http_got_header); } diff --git a/src/session/download.c b/src/session/download.c index a948b961a..dde81b15a 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -65,8 +65,6 @@ INIT_LIST_OF(struct file_download, downloads); -INIT_LIST_OF(struct popen_data, copiousoutput_data); - int download_is_progressing(struct download *download) { @@ -305,26 +303,16 @@ abort_download_and_beep(struct file_download *file_download, struct terminal *te } static void -read_from_popen(struct session *ses, unsigned char *handler, unsigned char *filename) +read_from_popen(struct session *ses, unsigned char *handler) { - FILE *stream = popen(handler, "r"); + FILE *pop = popen(handler, "r"); - if (stream) { - int fd = fileno(stream); + if (pop) { + int fd = fileno(pop); if (fd > 0) { unsigned char buf[48]; - struct popen_data *data = mem_calloc(1, sizeof(*data)); - - if (!data) { - fclose(stream); - return; - } - data->fd = fd; - data->stream = stream; - if (filename) data->filename = stracpy(filename); - add_to_list(copiousoutput_data, data); snprintf(buf, 48, "file:///dev/fd/%d", fd); goto_url(ses, buf); } @@ -370,10 +358,7 @@ download_data_store(struct download *download, struct file_download *file_downlo file_download->handle = -1; if (file_download->copiousoutput) { read_from_popen(file_download->ses, - file_download->external_handler, - file_download->file); - file_download->delete = 0; - abort_download_and_beep(file_download, term); + file_download->external_handler); } else { exec_on_terminal(term, file_download->external_handler, file_download->file, @@ -1101,7 +1086,7 @@ tp_open(struct type_query *type_query) if (handler) { if (type_query->copiousoutput) - read_from_popen(type_query->ses, handler, NULL); + read_from_popen(type_query->ses, handler); else exec_on_terminal(type_query->ses->tab->term, handler, "",