input/curl: don't abort if a packet has only metadata
When a received chunk of data has only icy-metadata, there was no usable data left for input_curl_read() to return, and thus it returned 0 bytes. "0" however is a special value for "end of file" or "error". This patch makes input_curl_read() read more data from the socket, until the read request can be fulfilled (or until there's really EOF).
This commit is contained in:
parent
016558093b
commit
af92b1c2d8
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
|||
ver 0.15.5 (2009/??/??)
|
||||
* input:
|
||||
- curl: don't abort if a packet has only metadata
|
||||
|
||||
|
||||
ver 0.15.4 (2009/10/03)
|
||||
|
|
|
@ -443,31 +443,33 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* fill the buffer */
|
||||
do {
|
||||
/* fill the buffer */
|
||||
|
||||
success = fill_buffer(is);
|
||||
if (!success)
|
||||
return 0;
|
||||
success = fill_buffer(is);
|
||||
if (!success)
|
||||
return 0;
|
||||
|
||||
/* send buffer contents */
|
||||
/* send buffer contents */
|
||||
|
||||
if (c->rewind != NULL &&
|
||||
(!g_queue_is_empty(c->rewind) || is->offset == 0))
|
||||
/* at the beginning or already writing the rewind
|
||||
buffer list */
|
||||
rewind_buffers = c->rewind;
|
||||
else
|
||||
/* we don't need the rewind buffers anymore */
|
||||
rewind_buffers = NULL;
|
||||
if (c->rewind != NULL &&
|
||||
(!g_queue_is_empty(c->rewind) || is->offset == 0))
|
||||
/* at the beginning or already writing the rewind
|
||||
buffer list */
|
||||
rewind_buffers = c->rewind;
|
||||
else
|
||||
/* we don't need the rewind buffers anymore */
|
||||
rewind_buffers = NULL;
|
||||
|
||||
while (size > 0 && !g_queue_is_empty(c->buffers)) {
|
||||
size_t copy = read_from_buffer(&c->icy_metadata, c->buffers,
|
||||
dest + nbytes, size,
|
||||
rewind_buffers);
|
||||
while (size > 0 && !g_queue_is_empty(c->buffers)) {
|
||||
size_t copy = read_from_buffer(&c->icy_metadata, c->buffers,
|
||||
dest + nbytes, size,
|
||||
rewind_buffers);
|
||||
|
||||
nbytes += copy;
|
||||
size -= copy;
|
||||
}
|
||||
nbytes += copy;
|
||||
size -= copy;
|
||||
}
|
||||
} while (nbytes == 0);
|
||||
|
||||
if (icy_defined(&c->icy_metadata))
|
||||
copy_icy_tag(c);
|
||||
|
|
Loading…
Reference in New Issue