209 if (home_path == NULL) { |
209 if (home_path == NULL) { |
210 return; |
210 return; |
211 } |
211 } |
212 strcpy(home_path, home_dir); |
212 strcpy(home_path, home_dir); |
213 Arguments::set_java_home(home_path); |
213 Arguments::set_java_home(home_path); |
214 FREE_C_HEAP_ARRAY(char, home_path, mtInternal); |
214 FREE_C_HEAP_ARRAY(char, home_path); |
215 |
215 |
216 dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1, |
216 dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1, |
217 mtInternal); |
217 mtInternal); |
218 if (dll_path == NULL) { |
218 if (dll_path == NULL) { |
219 return; |
219 return; |
220 } |
220 } |
221 strcpy(dll_path, home_dir); |
221 strcpy(dll_path, home_dir); |
222 strcat(dll_path, bin); |
222 strcat(dll_path, bin); |
223 Arguments::set_dll_dir(dll_path); |
223 Arguments::set_dll_dir(dll_path); |
224 FREE_C_HEAP_ARRAY(char, dll_path, mtInternal); |
224 FREE_C_HEAP_ARRAY(char, dll_path); |
225 |
225 |
226 if (!set_boot_path('\\', ';')) { |
226 if (!set_boot_path('\\', ';')) { |
227 return; |
227 return; |
228 } |
228 } |
229 } |
229 } |
274 } |
274 } |
275 |
275 |
276 strcat(library_path, ";."); |
276 strcat(library_path, ";."); |
277 |
277 |
278 Arguments::set_library_path(library_path); |
278 Arguments::set_library_path(library_path); |
279 FREE_C_HEAP_ARRAY(char, library_path, mtInternal); |
279 FREE_C_HEAP_ARRAY(char, library_path); |
280 } |
280 } |
281 |
281 |
282 // Default extensions directory |
282 // Default extensions directory |
283 { |
283 { |
284 char path[MAX_PATH]; |
284 char path[MAX_PATH]; |
1121 dirname = alt_dirname; |
1121 dirname = alt_dirname; |
1122 } |
1122 } |
1123 |
1123 |
1124 dirp->path = (char *)malloc(strlen(dirname) + 5, mtInternal); |
1124 dirp->path = (char *)malloc(strlen(dirname) + 5, mtInternal); |
1125 if (dirp->path == 0) { |
1125 if (dirp->path == 0) { |
1126 free(dirp, mtInternal); |
1126 free(dirp); |
1127 errno = ENOMEM; |
1127 errno = ENOMEM; |
1128 return 0; |
1128 return 0; |
1129 } |
1129 } |
1130 strcpy(dirp->path, dirname); |
1130 strcpy(dirp->path, dirname); |
1131 |
1131 |
1132 fattr = GetFileAttributes(dirp->path); |
1132 fattr = GetFileAttributes(dirp->path); |
1133 if (fattr == 0xffffffff) { |
1133 if (fattr == 0xffffffff) { |
1134 free(dirp->path, mtInternal); |
1134 free(dirp->path); |
1135 free(dirp, mtInternal); |
1135 free(dirp); |
1136 errno = ENOENT; |
1136 errno = ENOENT; |
1137 return 0; |
1137 return 0; |
1138 } else if ((fattr & FILE_ATTRIBUTE_DIRECTORY) == 0) { |
1138 } else if ((fattr & FILE_ATTRIBUTE_DIRECTORY) == 0) { |
1139 free(dirp->path, mtInternal); |
1139 free(dirp->path); |
1140 free(dirp, mtInternal); |
1140 free(dirp); |
1141 errno = ENOTDIR; |
1141 errno = ENOTDIR; |
1142 return 0; |
1142 return 0; |
1143 } |
1143 } |
1144 |
1144 |
1145 // Append "*.*", or possibly "\\*.*", to path |
1145 // Append "*.*", or possibly "\\*.*", to path |
1192 errno = EBADF; |
1192 errno = EBADF; |
1193 return -1; |
1193 return -1; |
1194 } |
1194 } |
1195 dirp->handle = INVALID_HANDLE_VALUE; |
1195 dirp->handle = INVALID_HANDLE_VALUE; |
1196 } |
1196 } |
1197 free(dirp->path, mtInternal); |
1197 free(dirp->path); |
1198 free(dirp, mtInternal); |
1198 free(dirp); |
1199 return 0; |
1199 return 0; |
1200 } |
1200 } |
1201 |
1201 |
1202 // This must be hard coded because it's the system's temporary |
1202 // This must be hard coded because it's the system's temporary |
1203 // directory not the java application's temp directory, ala java.io.tmpdir. |
1203 // directory not the java application's temp directory, ala java.io.tmpdir. |
1260 } |
1260 } |
1261 } |
1261 } |
1262 // release the storage |
1262 // release the storage |
1263 for (int i = 0; i < n; i++) { |
1263 for (int i = 0; i < n; i++) { |
1264 if (pelements[i] != NULL) { |
1264 if (pelements[i] != NULL) { |
1265 FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); |
1265 FREE_C_HEAP_ARRAY(char, pelements[i]); |
1266 } |
1266 } |
1267 } |
1267 } |
1268 if (pelements != NULL) { |
1268 if (pelements != NULL) { |
1269 FREE_C_HEAP_ARRAY(char*, pelements, mtInternal); |
1269 FREE_C_HEAP_ARRAY(char*, pelements); |
1270 } |
1270 } |
1271 } else { |
1271 } else { |
1272 jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname); |
1272 jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname); |
1273 retval = true; |
1273 retval = true; |
1274 } |
1274 } |
2730 int *_numa_used_node_list; // allocated below |
2730 int *_numa_used_node_list; // allocated below |
2731 int _numa_used_node_count; |
2731 int _numa_used_node_count; |
2732 |
2732 |
2733 void free_node_list() { |
2733 void free_node_list() { |
2734 if (_numa_used_node_list != NULL) { |
2734 if (_numa_used_node_list != NULL) { |
2735 FREE_C_HEAP_ARRAY(int, _numa_used_node_list, mtInternal); |
2735 FREE_C_HEAP_ARRAY(int, _numa_used_node_list); |
2736 } |
2736 } |
2737 } |
2737 } |
2738 |
2738 |
2739 public: |
2739 public: |
2740 NUMANodeListHolder() { |
2740 NUMANodeListHolder() { |
3766 jio_snprintf(ebuf, ebuflen, |
3766 jio_snprintf(ebuf, ebuflen, |
3767 "os::win32::load_windows_dll() cannot load %s from system directories.", name); |
3767 "os::win32::load_windows_dll() cannot load %s from system directories.", name); |
3768 return NULL; |
3768 return NULL; |
3769 } |
3769 } |
3770 |
3770 |
3771 #define MAX_EXIT_HANDLES 16 |
3771 #define MAX_EXIT_HANDLES PRODUCT_ONLY(32) NOT_PRODUCT(128) |
3772 #define EXIT_TIMEOUT 1000 /* 1 sec */ |
3772 #define EXIT_TIMEOUT PRODUCT_ONLY(1000) NOT_PRODUCT(4000) /* 1 sec in product, 4 sec in debug */ |
3773 |
3773 |
3774 static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) { |
3774 static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) { |
3775 InitializeCriticalSection((CRITICAL_SECTION*)pcrit_sect); |
3775 InitializeCriticalSection((CRITICAL_SECTION*)pcrit_sect); |
3776 return TRUE; |
3776 return TRUE; |
3777 } |
3777 } |
3818 } |
3818 } |
3819 |
3819 |
3820 // If there's no free slot in the array of the kept handles, we'll have to |
3820 // If there's no free slot in the array of the kept handles, we'll have to |
3821 // wait until at least one thread completes exiting. |
3821 // wait until at least one thread completes exiting. |
3822 if ((handle_count = j) == MAX_EXIT_HANDLES) { |
3822 if ((handle_count = j) == MAX_EXIT_HANDLES) { |
|
3823 // Raise the priority of the oldest exiting thread to increase its chances |
|
3824 // to complete sooner. |
|
3825 SetThreadPriority(handles[0], THREAD_PRIORITY_ABOVE_NORMAL); |
3823 res = WaitForMultipleObjects(MAX_EXIT_HANDLES, handles, FALSE, EXIT_TIMEOUT); |
3826 res = WaitForMultipleObjects(MAX_EXIT_HANDLES, handles, FALSE, EXIT_TIMEOUT); |
3824 if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) { |
3827 if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) { |
3825 i = (res - WAIT_OBJECT_0); |
3828 i = (res - WAIT_OBJECT_0); |
3826 handle_count = MAX_EXIT_HANDLES - 1; |
3829 handle_count = MAX_EXIT_HANDLES - 1; |
3827 for (; i < handle_count; ++i) { |
3830 for (; i < handle_count; ++i) { |
3828 handles[i] = handles[i + 1]; |
3831 handles[i] = handles[i + 1]; |
3829 } |
3832 } |
3830 } else { |
3833 } else { |
3831 warning("WaitForMultipleObjects failed in %s: %d\n", __FILE__, __LINE__); |
3834 warning("WaitForMultipleObjects %s in %s: %d\n", |
|
3835 (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__); |
3832 // Don't keep handles, if we failed waiting for them. |
3836 // Don't keep handles, if we failed waiting for them. |
3833 for (i = 0; i < MAX_EXIT_HANDLES; ++i) { |
3837 for (i = 0; i < MAX_EXIT_HANDLES; ++i) { |
3834 CloseHandle(handles[i]); |
3838 CloseHandle(handles[i]); |
3835 } |
3839 } |
3836 handle_count = 0; |
3840 handle_count = 0; |
3852 |
3856 |
3853 } else { // what != EPT_THREAD |
3857 } else { // what != EPT_THREAD |
3854 if (handle_count > 0) { |
3858 if (handle_count > 0) { |
3855 // Before ending the process, make sure all the threads that had called |
3859 // Before ending the process, make sure all the threads that had called |
3856 // _endthreadex() completed. |
3860 // _endthreadex() completed. |
|
3861 |
|
3862 // Set the priority level of the current thread to the same value as |
|
3863 // the priority level of exiting threads. |
|
3864 // This is to ensure it will be given a fair chance to execute if |
|
3865 // the timeout expires. |
|
3866 hthr = GetCurrentThread(); |
|
3867 SetThreadPriority(hthr, THREAD_PRIORITY_ABOVE_NORMAL); |
|
3868 for (i = 0; i < handle_count; ++i) { |
|
3869 SetThreadPriority(handles[i], THREAD_PRIORITY_ABOVE_NORMAL); |
|
3870 } |
3857 res = WaitForMultipleObjects(handle_count, handles, TRUE, EXIT_TIMEOUT); |
3871 res = WaitForMultipleObjects(handle_count, handles, TRUE, EXIT_TIMEOUT); |
3858 if (res == WAIT_FAILED) { |
3872 if (res < WAIT_OBJECT_0 || res >= (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) { |
3859 warning("WaitForMultipleObjects failed in %s: %d\n", __FILE__, __LINE__); |
3873 warning("WaitForMultipleObjects %s in %s: %d\n", |
|
3874 (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__); |
3860 } |
3875 } |
3861 for (i = 0; i < handle_count; ++i) { |
3876 for (i = 0; i < handle_count; ++i) { |
3862 CloseHandle(handles[i]); |
3877 CloseHandle(handles[i]); |
3863 } |
3878 } |
3864 handle_count = 0; |
3879 handle_count = 0; |
4629 return FALSE; |
4644 return FALSE; |
4630 } |
4645 } |
4631 |
4646 |
4632 error = ::PeekConsoleInput(han, lpBuffer, numEvents, &numEventsRead); |
4647 error = ::PeekConsoleInput(han, lpBuffer, numEvents, &numEventsRead); |
4633 if (error == 0) { |
4648 if (error == 0) { |
4634 os::free(lpBuffer, mtInternal); |
4649 os::free(lpBuffer); |
4635 return FALSE; |
4650 return FALSE; |
4636 } |
4651 } |
4637 |
4652 |
4638 // Examine input records for the number of bytes available |
4653 // Examine input records for the number of bytes available |
4639 for (i=0; i<numEvents; i++) { |
4654 for (i=0; i<numEvents; i++) { |