Explorar el Código

make sure the mmap based io_sendfile actually works (and terminates)

master
Felix von Leitner hace 17 años
padre
commit
5c92fb9e03
Se han modificado 2 ficheros con 9 adiciones y 3 borrados
  1. +2
    -3
      io/io_sendfile.c
  2. +7
    -0
      t.c

+ 2
- 3
io/io_sendfile.c Ver fichero

@@ -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
- 0
t.c Ver fichero

@@ -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");


Cargando…
Cancelar
Guardar