Fix fd leak

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent 418c93880d
commit c6bd0d66b7

@ -555,8 +555,11 @@ void li_chunkqueue_append_file(liChunkQueue *cq, GString *filename, off_t start,
/* if you already opened the file, you can pass the fd here - do not close it */
void li_chunkqueue_append_file_fd(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd) {
if (length)
if (length) {
__chunkqueue_append_file(cq, filename, start, length, fd, FALSE);
} else {
if (-1 != fd) close(fd);
}
}
/* temp files get deleted after usage */
@ -570,6 +573,10 @@ void li_chunkqueue_append_tempfile(liChunkQueue *cq, GString *filename, off_t st
void li_chunkqueue_append_tempfile_fd(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd) {
if (length)
__chunkqueue_append_file(cq, filename, start, length, fd, TRUE);
else {
if (-1 != fd) close(fd);
unlink(filename->str);
}
}
/* steal up to length bytes from in and put them into out, return number of bytes stolen */

@ -304,7 +304,7 @@ static liAction* core_index(liServer *srv, liPlugin* p, liValue *val) {
static liHandlerResult core_handle_static(liVRequest *vr, gpointer param, gpointer *context) {
int fd;
int fd = -1;
struct stat st;
int err;
liHandlerResult res;

Loading…
Cancel
Save