http: fix error handling in the fallback read/write path
This commit is contained in:
parent
e2cebb68e1
commit
08c21f39d1
12
upnphttp.c
12
upnphttp.c
@ -1284,21 +1284,25 @@ send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset)
|
|||||||
/* Fall back to regular I/O */
|
/* Fall back to regular I/O */
|
||||||
if( !buf )
|
if( !buf )
|
||||||
buf = malloc(MIN_BUFFER_SIZE);
|
buf = malloc(MIN_BUFFER_SIZE);
|
||||||
send_size = ( ((end_offset - offset) < MIN_BUFFER_SIZE) ? (end_offset - offset + 1) : MIN_BUFFER_SIZE);
|
send_size = (((end_offset - offset) < MIN_BUFFER_SIZE) ? (end_offset - offset + 1) : MIN_BUFFER_SIZE);
|
||||||
lseek(sendfd, offset, SEEK_SET);
|
lseek(sendfd, offset, SEEK_SET);
|
||||||
ret = read(sendfd, buf, send_size);
|
ret = read(sendfd, buf, send_size);
|
||||||
if( ret == -1 ) {
|
if( ret == -1 ) {
|
||||||
DPRINTF(E_DEBUG, L_HTTP, "read error :: error no. %d [%s]\n", errno, strerror(errno));
|
DPRINTF(E_DEBUG, L_HTTP, "read error :: error no. %d [%s]\n", errno, strerror(errno));
|
||||||
if( errno != EAGAIN )
|
if( errno == EAGAIN )
|
||||||
|
continue;
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = write(h->socket, buf, ret);
|
ret = write(h->socket, buf, ret);
|
||||||
if( ret == -1 ) {
|
if( ret == -1 ) {
|
||||||
DPRINTF(E_DEBUG, L_HTTP, "write error :: error no. %d [%s]\n", errno, strerror(errno));
|
DPRINTF(E_DEBUG, L_HTTP, "write error :: error no. %d [%s]\n", errno, strerror(errno));
|
||||||
if( errno != EAGAIN )
|
if( errno == EAGAIN )
|
||||||
|
continue;
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
offset+=ret;
|
offset += ret;
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user