equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
121 NULL, /* Security attributes */ |
121 NULL, /* Security attributes */ |
122 disposition, /* creation disposition */ |
122 disposition, /* creation disposition */ |
123 flagsAndAttributes, /* flags and attributes */ |
123 flagsAndAttributes, /* flags and attributes */ |
124 NULL); |
124 NULL); |
125 #else |
125 #else |
126 return JVM_Open(fname, flags, 0); |
126 return open(fname, flags, 0); |
127 #endif |
127 #endif |
128 } |
128 } |
129 |
129 |
130 /* |
130 /* |
131 * The io_util_md.h files do not provide IO_CLOSE, hence we use platform |
131 * The io_util_md.h files do not provide IO_CLOSE, hence we use platform |
134 static void |
134 static void |
135 ZFILE_Close(ZFILE zfd) { |
135 ZFILE_Close(ZFILE zfd) { |
136 #ifdef WIN32 |
136 #ifdef WIN32 |
137 CloseHandle((HANDLE) zfd); |
137 CloseHandle((HANDLE) zfd); |
138 #else |
138 #else |
139 JVM_Close(zfd); |
139 close(zfd); |
140 #endif |
140 #endif |
141 } |
141 } |
142 |
142 |
143 static int |
143 static int |
144 ZFILE_read(ZFILE zfd, char *buf, jint nbytes) { |
144 ZFILE_read(ZFILE zfd, char *buf, jint nbytes) { |
145 #ifdef WIN32 |
145 #ifdef WIN32 |
146 return (int) IO_Read(zfd, buf, nbytes); |
146 return (int) IO_Read(zfd, buf, nbytes); |
147 #else |
147 #else |
148 /* |
|
149 * Calling JVM_Read will return JVM_IO_INTR when Thread.interrupt is called |
|
150 * only on Solaris. Continue reading jar file in this case is the best |
|
151 * thing to do since zip file reading is relatively fast and it is very onerous |
|
152 * for a interrupted thread to deal with this kind of hidden I/O. However, handling |
|
153 * JVM_IO_INTR is tricky and could cause undesired side effect. So we decided |
|
154 * to simply call "read" on Solaris/Linux. See details in bug 6304463. |
|
155 */ |
|
156 return read(zfd, buf, nbytes); |
148 return read(zfd, buf, nbytes); |
157 #endif |
149 #endif |
158 } |
150 } |
159 |
151 |
160 /* |
152 /* |
196 (jint) limit; |
188 (jint) limit; |
197 jint n = ZFILE_read(zfd, bp, count); |
189 jint n = ZFILE_read(zfd, bp, count); |
198 if (n > 0) { |
190 if (n > 0) { |
199 bp += n; |
191 bp += n; |
200 len -= n; |
192 len -= n; |
201 } else if (n == JVM_IO_ERR && errno == EINTR) { |
193 } else if (n == -1 && errno == EINTR) { |
202 /* Retry after EINTR (interrupted by signal). |
194 /* Retry after EINTR (interrupted by signal). */ |
203 We depend on the fact that JVM_IO_ERR == -1. */ |
|
204 continue; |
195 continue; |
205 } else { /* EOF or IO error */ |
196 } else { /* EOF or IO error */ |
206 return -1; |
197 return -1; |
207 } |
198 } |
208 } |
199 } |
826 #endif |
817 #endif |
827 zip->refs = 1; |
818 zip->refs = 1; |
828 zip->lastModified = lastModified; |
819 zip->lastModified = lastModified; |
829 |
820 |
830 if (zfd == -1) { |
821 if (zfd == -1) { |
831 if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0) |
822 if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0) |
832 *pmsg = strdup(errbuf); |
823 *pmsg = strdup(errbuf); |
833 freeZip(zip); |
824 freeZip(zip); |
834 return NULL; |
825 return NULL; |
835 } |
826 } |
836 |
827 |
847 if (len == 0) { /* zip file is empty */ |
838 if (len == 0) { /* zip file is empty */ |
848 if (pmsg) { |
839 if (pmsg) { |
849 *pmsg = strdup("zip file is empty"); |
840 *pmsg = strdup("zip file is empty"); |
850 } |
841 } |
851 } else { /* error */ |
842 } else { /* error */ |
852 if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0) |
843 if (pmsg && getLastErrorString(errbuf, sizeof(errbuf)) > 0) |
853 *pmsg = strdup(errbuf); |
844 *pmsg = strdup(errbuf); |
854 } |
845 } |
855 ZFILE_Close(zfd); |
846 ZFILE_Close(zfd); |
856 freeZip(zip); |
847 freeZip(zip); |
857 return NULL; |
848 return NULL; |