libventi fixes Reference: /n/sources/patch/applied/libventi Date: Sun Jun 15 05:00:18 CES 2008 Signed-off-by: rsc@swtch.com --- /sys/src/libventi/file.c Sun Jun 15 05:00:13 2008 +++ /sys/src/libventi/file.c Sun Jun 15 05:00:12 2008 @@ -607,7 +607,7 @@ rb = vtcacheglobal(r->c, e->score, e->type); if(rb == nil) - return 0; + return -1; /* * Walk down to the new root block. @@ -748,6 +748,12 @@ if(b == nil) return -1; + if(DEPTH(e.type) == 0){ + memmove(score, e.score, VtScoreSize); + vtblockput(b); + return 0; + } + i = mkindices(&e, bn, index); if(i < 0){ vtblockput(b); @@ -1058,6 +1064,8 @@ return -1; memmove(b->data+frag, data, count); + if(m == VtOWRITE && frag+count < e.dsize) + memset(b->data+frag+count, 0, e.dsize-frag-count); if(offset+count > e.size){ vtfilegetentry(f, &e); @@ -1118,9 +1126,12 @@ for(i=0; idata, i) < 0) goto Err; + if(!(e.flags&VtEntryActive)) + continue; if(flushblock(c, nil, e.score, e.psize/VtScoreSize, e.dsize/VtEntrySize, e.type) < 0) goto Err; + vtentrypack(&e, b->data, i); } break; --- /sys/src/libventi/log.c Sun Jun 15 05:00:14 2008 +++ /sys/src/libventi/log.c Sun Jun 15 05:00:13 2008 @@ -169,18 +169,11 @@ { static uvlong t0; uvlong t; - Tm tm; - if(fmt->flags&FmtSharp){ - if(t0 == 0) - t0 = nsec(); - t = nsec()-t0; - return fmtprint(fmt, "T+%d.%04d", (uint)(t/1000000000), (uint)(t%1000000000)/100000); - }else{ - tm = *localtime(time(0)); - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d", - 1900+tm.year, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec); - } + if(t0 == 0) + t0 = nsec(); + t = nsec()-t0; + return fmtprint(fmt, "T+%d.%04d", (uint)(t/1000000000), (uint)(t%1000000000)/100000); } void --- /sys/src/libventi/packet.c Sun Jun 15 05:00:14 2008 +++ /sys/src/libventi/packet.c Sun Jun 15 05:00:14 2008 @@ -888,7 +888,7 @@ if(n < 0 || n > MaxFragSize) { werrstr(EPacketSize); - return 0; + return nil; } if(n <= SmallMemSize) { lock(&freelist.lk); --- /sys/src/libventi/send.c Sun Jun 15 05:00:15 2008 +++ /sys/src/libventi/send.c Sun Jun 15 05:00:14 2008 @@ -39,7 +39,7 @@ if(write(z->outfd, ioc.addr, ioc.len) < ioc.len){ vtlog(VtServerLog, "%T %s: sending packet %p: %r
\n", z->addr, p); packetfree(p); - return 0; + return -1; } packetconsume(p, nil, ioc.len); tot += ioc.len;