make sure the mmap based io_sendfile actually works (and terminates)
This commit is contained in:
parent
3fe23979fd
commit
3cac9c2b80
@ -60,13 +60,12 @@ int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
|
||||
if (off>=e->mapofs && off<e->mapofs+e->maplen)
|
||||
goto mapok; /* ok; mmapped the right chunk*/
|
||||
munmap(e->mmapped,e->maplen);
|
||||
e->mmapped=0;
|
||||
}
|
||||
e->mapofs=off&0xffffffffffff0000ull;
|
||||
if (e->mapofs+0xffff>off+bytes)
|
||||
if (e->mapofs+0x10000>off+bytes)
|
||||
e->maplen=off+bytes-e->mapofs;
|
||||
else
|
||||
e->maplen=0xffff;
|
||||
e->maplen=0x10000;
|
||||
if ((e->mmapped=mmap(0,e->maplen,PROT_READ,MAP_SHARED,in,e->mapofs))==MAP_FAILED) {
|
||||
e->mmapped=0;
|
||||
goto readwrite;
|
||||
|
7
t.c
7
t.c
@ -23,12 +23,19 @@
|
||||
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
char buf[100];
|
||||
int i;
|
||||
printf("%d\n",i=fmt_pad(buf,"fnord",5,7,10));
|
||||
buf[i]=0;
|
||||
puts(buf);
|
||||
#if 0
|
||||
char ip[16];
|
||||
char buf[32];
|
||||
printf("%d (expect 2)\n",scan_ip6("::",ip));
|
||||
printf("%d (expect 3)\n",scan_ip6("::1",ip));
|
||||
printf("%d (expect 16)\n",scan_ip6("fec0:0:0:ffff::1/0",ip));
|
||||
printf("%.*s\n",fmt_ip6(buf,ip),buf);
|
||||
#endif
|
||||
#if 0
|
||||
static stralloc s,t;
|
||||
stralloc_copys(&s,"fnord");
|
||||
|
Loading…
x
Reference in New Issue
Block a user