fix descriptor leak in iob_addfile_close if the range was 0 (oops)
This commit is contained in:
parent
1205a3d38f
commit
11da04b651
1
CHANGES
1
CHANGES
@ -8,6 +8,7 @@
|
|||||||
document that the iob_write callback should limit itself
|
document that the iob_write callback should limit itself
|
||||||
fix mmap_shared
|
fix mmap_shared
|
||||||
add iob_free, add man pages for iob_free and iob_reset
|
add iob_free, add man pages for iob_free and iob_reset
|
||||||
|
fix descriptor leak in iob_addfile_close if the range was 0 (oops)
|
||||||
|
|
||||||
0.21:
|
0.21:
|
||||||
errno cleanup and man page updates (Rolf Eike Beer)
|
errno cleanup and man page updates (Rolf Eike Beer)
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#include "iob_internal.h"
|
#include "iob_internal.h"
|
||||||
|
|
||||||
int iob_addbuf_internal(io_batch* b,const void* buf,uint64 n,int _free) {
|
int iob_addbuf_internal(io_batch* b,const void* buf,uint64 n,int _free) {
|
||||||
iob_entry* e=array_allocate(&b->b,sizeof(iob_entry),
|
iob_entry* e;
|
||||||
array_length(&b->b,sizeof(iob_entry)));
|
if (!n) {
|
||||||
|
if (_free) free(buf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
e=array_allocate(&b->b,sizeof(iob_entry),array_length(&b->b,sizeof(iob_entry)));
|
||||||
if (!e) return 0;
|
if (!e) return 0;
|
||||||
e->type=_free?FROMBUF_FREE:FROMBUF;
|
e->type=_free?FROMBUF_FREE:FROMBUF;
|
||||||
e->fd=-1;
|
e->fd=-1;
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n) {
|
int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n) {
|
||||||
iob_entry* e;
|
iob_entry* e;
|
||||||
if (n==0) return 1;
|
if (n==0) {
|
||||||
|
io_close(fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
io_fd(fd);
|
io_fd(fd);
|
||||||
e=array_allocate(&b->b,sizeof(iob_entry),
|
e=array_allocate(&b->b,sizeof(iob_entry),
|
||||||
array_length(&b->b,sizeof(iob_entry)));
|
array_length(&b->b,sizeof(iob_entry)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user