mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
This commit is contained in:
commit
c73e4e8d65
@ -308,8 +308,8 @@ ecmascript_timeout_handler(void *i)
|
||||
{
|
||||
struct ecmascript_interpreter *interpreter = i;
|
||||
|
||||
assert(interpreter->vs->doc_view->document);
|
||||
kill_timer(&interpreter->vs->doc_view->document->timeout);
|
||||
assertm(interpreter->vs->doc_view, "setTimeout: vs with no document (e_f %d)", interpreter->vs->ecmascript_fragile);
|
||||
interpreter->vs->doc_view->document->timeout = TIMER_ID_UNDEF;
|
||||
|
||||
ecmascript_eval(interpreter, &interpreter->code, NULL);
|
||||
}
|
||||
@ -323,6 +323,7 @@ ecmascript_set_timeout(struct ecmascript_interpreter *interpreter, unsigned char
|
||||
init_string(&interpreter->code);
|
||||
add_to_string(&interpreter->code, code);
|
||||
mem_free(code);
|
||||
kill_timer(&interpreter->vs->doc_view->document->timeout);
|
||||
install_timer(&interpreter->vs->doc_view->document->timeout, timeout, ecmascript_timeout_handler, interpreter);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ gzip_open(struct stream_encoded *stream, int fd)
|
||||
static int
|
||||
gzip_read(struct stream_encoded *stream, unsigned char *data, int len)
|
||||
{
|
||||
gzclearerr((gzFile *) stream->data);
|
||||
return gzread((gzFile *) stream->data, data, len);
|
||||
}
|
||||
|
||||
|
@ -960,7 +960,8 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
* causes further malfunction of zlib :[ ... so we will make sure that
|
||||
* we will always have at least PIPE_BUF / 2 + 1 in the pipe (returning
|
||||
* early otherwise)). */
|
||||
int to_read = PIPE_BUF / 2, did_read = 0;
|
||||
enum { NORMAL, FINISHING } state = NORMAL;
|
||||
int did_read = 0;
|
||||
int *length_of_block;
|
||||
unsigned char *output = NULL;
|
||||
|
||||
@ -970,9 +971,7 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
#define BIG_READ 65536
|
||||
if (!*length_of_block) {
|
||||
/* Going to finish this decoding bussiness. */
|
||||
/* Some nicely big value - empty encoded output queue by reading
|
||||
* big chunks from it. */
|
||||
to_read = BIG_READ;
|
||||
state = FINISHING;
|
||||
}
|
||||
|
||||
if (conn->content_encoding == ENCODING_NONE) {
|
||||
@ -991,11 +990,14 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
}
|
||||
|
||||
do {
|
||||
int init = 0;
|
||||
int to_read;
|
||||
|
||||
if (to_read == PIPE_BUF / 2) {
|
||||
if (state == NORMAL) {
|
||||
/* ... we aren't finishing yet. */
|
||||
int written = safe_write(conn->stream_pipes[1], data,
|
||||
int written;
|
||||
|
||||
to_read = PIPE_BUF / 2;
|
||||
written = safe_write(conn->stream_pipes[1], data,
|
||||
len > to_read ? to_read : len);
|
||||
|
||||
if (written > 0) {
|
||||
@ -1009,7 +1011,7 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
* non-keep-alive and chunked */
|
||||
if (!http->length) {
|
||||
/* That's all, folks - let's finish this. */
|
||||
to_read = BIG_READ;
|
||||
state = FINISHING;
|
||||
} else if (!len) {
|
||||
/* We've done for this round (but not done
|
||||
* completely). Thus we will get out with
|
||||
@ -1022,6 +1024,11 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
return output;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* state is FINISHING. Set to_read to some nice, big
|
||||
* value to empty the encoded output queue by reading
|
||||
* big chunks from it. */
|
||||
to_read = BIG_READ;
|
||||
}
|
||||
|
||||
if (!conn->stream) {
|
||||
@ -1030,14 +1037,17 @@ decompress_data(struct connection *conn, unsigned char *data, int len,
|
||||
if (!conn->stream) return NULL;
|
||||
/* On "startup" pipe is treated with care, but if everything
|
||||
* was already written to the pipe, caution isn't necessary */
|
||||
else if (to_read != BIG_READ) init = 1;
|
||||
} else init = 0;
|
||||
if (state != FINISHING) {
|
||||
/* on init don't read too much */
|
||||
to_read = PIPE_BUF / 32;
|
||||
}
|
||||
}
|
||||
|
||||
output = (unsigned char *) mem_realloc(output, *new_len + to_read);
|
||||
if (!output) break;
|
||||
|
||||
did_read = read_encoded(conn->stream, output + *new_len,
|
||||
init ? PIPE_BUF / 32 : to_read); /* on init don't read too much */
|
||||
to_read);
|
||||
if (did_read > 0) *new_len += did_read;
|
||||
else if (did_read == -1) {
|
||||
mem_free_set(&output, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user