Author: archie Date: Fri Jan 20 07:10:30 2006 New Revision: 370844 URL: http://svn.apache.org/viewcvs?rev=370844&view=rev Log: Oops, revert r370843, having just now remembered why pread(2) is used instead of lseek(2)/read(2): ZIP file entries may be read by multiple threads simultaneously, and therefore they can't all use the same file pointer into the file. Modified: incubator/harmony/enhanced/jchevm/libjc/zip.c Modified: incubator/harmony/enhanced/jchevm/libjc/zip.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/zip.c?rev=370844&r1=370843&r2=370844&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/zip.c (original) +++ incubator/harmony/enhanced/jchevm/libjc/zip.c Fri Jan 20 07:10:30 2006 @@ -306,18 +306,10 @@ return JNI_ERR; } - /* Seek to start of data */ - if (lseek(zip->fd, zent->offset, SEEK_SET) == -1) { - _JC_EX_STORE(env, IOException, "can't seek entry `%s'" - " in ZIP file `%s': %s", zent->name, zip->path, - strerror(errno)); - return JNI_ERR; - } - /* Read data */ for (i = 0; i < zent->comp_len; i += r) { - if ((r = read(zip->fd, (char *)data + i, - zent->comp_len - i)) == -1) { + if ((r = pread(zip->fd, (char *)data + i, + zent->comp_len - i, zent->offset + i)) == -1) { _JC_EX_STORE(env, IOException, "can't read entry `%s'" " in ZIP file `%s': %s", zent->name, zip->path, strerror(errno)); @@ -368,14 +360,6 @@ _JC_ASSERT(JNI_FALSE); } - /* Seek to start of data */ - if (lseek(zip->fd, zent->offset, SEEK_SET) == -1) { - _JC_EX_STORE(env, IOException, "can't seek entry `%s' in" - " ZIP file `%s': %s", zent->name, zip->path, - strerror(errno)); - return JNI_ERR; - } - /* Read and inflate data */ for (i = 0; i < zent->comp_len; i += r) { char buf[512]; @@ -386,8 +370,9 @@ to_read = zent->comp_len - i; if (to_read > sizeof(buf)) to_read = sizeof(buf); - if ((r = read(zip->fd, buf, to_read)) == -1) { - _JC_EX_STORE(env, IOException, "can't read entry" + if ((r = pread(zip->fd, buf, + to_read, zent->offset + i)) == -1) { + _JC_EX_STORE(env, IOException, "error reading entry" " `%s' in ZIP file `%s': %s", zent->name, zip->path, strerror(errno)); goto fail;