Thanks for this patch, kuer. I'll apply it. - Doug
On Mon, Jul 20, 2009 at 8:28 PM, kuer <[email protected]> wrote: > > Hi, all, > > According pread() manual : > > ssize_t pread(int fd, void *buf, size_t count, off_t offset); > > pread() reads up to count bytes from file descriptor fd at offset > offset (from the start of the file) into the buffer starting at buf. > The file offset is not changed. > > I think KosmosBroker::pread() should maintain the same semantic. > > $ svn diff > Index: KosmosBroker.cc > =================================================================== > --- KosmosBroker.cc (revision 28219) > +++ KosmosBroker.cc (working copy) > @@ -312,6 +312,7 @@ > ssize_t nread; > KfsClientPtr clnt = KFS::getKfsClientFactory()->GetClient(); > StaticBuffer buf(new uint8_t [amount], amount); > + uint64_t offset_last; > > HT_DEBUGF("pread fd=%d offset=%lld amount=%d", fd, (Lld)offset, > amount); > > @@ -322,6 +323,9 @@ > return; > } > > + // remember the last offset before pread() > + offset_last = clnt->Tell(fdata->fd); > + > if ((offset = (uint64_t) clnt->Seek(fdata->fd, offset, SEEK_SET)) > == (uint64_t) -1) { > string errmsg = KFS::ErrorCodeToStr(offset); > @@ -339,6 +343,16 @@ > return; > } > > + // restore the last offset when pread() done > + if ((offset = (uint64_t) clnt->Seek(fdata->fd, offset_last, > SEEK_SET)) > + == (uint64_t) -1) { > + string errmsg = KFS::ErrorCodeToStr(offset_last); > + HT_ERRORF("lseek failed: fd=%d offset=%lld - %s", fdata->fd, (Lld) > offset_last, > + errmsg.c_str()); > + report_error(cb, (int) offset); > + return; > + } > + > buf.size = nread; > > cb->response(offset, buf); > > > Thanks > > -- kuer > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hypertable Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hypertable-dev?hl=en -~----------~----~----~----~------~----~------~--~---
