Changeset 2878 in kBuild
- Timestamp:
- Sep 5, 2016 7:54:49 PM (8 years ago)
- Location:
- trunk/src/kWorker
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/Makefile.kmk
r2860 r2878 40 40 kWorker_LIBS.win = \ 41 41 $(TEMPLATE_BIN-STATIC-THREADED_LIBS) \ 42 $(PATH_SDK_WINDDK71_LIB_WNET)/ntdll.lib 42 $(PATH_SDK_WINDDK71_LIB_WNET)/ntdll.lib \ 43 $(PATH_SDK_WINDDK71_LIB_WNET)/psapi.lib 43 44 kWorker_LDFLAGS.win = \ 44 45 /BASE:0x10000 /DYNAMICBASE:NO /FIXED /SECTION:DefLdBuf,EWR -
trunk/src/kWorker/kWorker.c
r2877 r2878 32 32 *********************************************************************************************************************************/ 33 33 //#undef NDEBUG 34 #define PSAPI_VERSION 1 34 35 #include <k/kHlp.h> 35 36 #include <k/kLdr.h> … … 47 48 48 49 #include "nt/ntstuff.h" 50 #include <psapi.h> 49 51 50 52 #include "nt/kFsCache.h" … … 5954 5956 5955 5957 5956 static void kwSandboxCleanup(PKWSANDBOX pSandbox) 5957 { 5958 PKWVIRTALLOC pTracker; 5959 PKWLOCALSTORAGE pLocalStorage; 5958 /** 5959 * Does sandbox cleanup between jobs. 5960 * 5961 * We postpone whatever isn't externally visible (i.e. files) and doesn't 5962 * influence the result, so that kmk can get on with things ASAP. 5963 * 5964 * @param pSandbox The sandbox. 5965 */ 5966 static void kwSandboxCleanupLate(PKWSANDBOX pSandbox) 5967 { 5968 PROCESS_MEMORY_COUNTERS MemInfo; 5969 PKWVIRTALLOC pTracker; 5970 PKWLOCALSTORAGE pLocalStorage; 5960 5971 #ifdef WITH_TEMP_MEMORY_FILES 5961 PKWFSTEMPFILE pTempFile; 5962 #endif 5963 PPEB pPeb = kwSandboxGetProcessEnvironmentBlock(); 5964 pPeb->ProcessParameters->CommandLine = pSandbox->SavedCommandLine; 5965 /** @todo lots more to do here! */ 5966 5967 #ifdef WITH_TEMP_MEMORY_FILES 5972 PKWFSTEMPFILE pTempFile; 5973 5974 /* The temporary files aren't externally visible, they're all in memory. */ 5968 5975 pTempFile = pSandbox->pTempFileHead; 5969 5976 pSandbox->pTempFileHead = NULL; … … 6018 6025 } 6019 6026 6027 6020 6028 /* Free the environment. */ 6021 6029 if (pSandbox->papszEnvVars) … … 6032 6040 pSandbox->papwszEnvVars[0] = NULL; 6033 6041 } 6042 6043 /* 6044 * Check the memory usage. If it's getting high, trigger a respawn 6045 * after the next job. 6046 */ 6047 MemInfo.WorkingSetSize = 0; 6048 if (GetProcessMemoryInfo(GetCurrentProcess(), &MemInfo, sizeof(MemInfo))) 6049 { 6050 #if K_ARCH_BITS >= 64 6051 if (MemInfo.WorkingSetSize >= 512*1024*1024) 6052 #else 6053 if (MemInfo.WorkingSetSize >= 384*1024*1024) 6054 #endif 6055 { 6056 KW_LOG(("WorkingSetSize = %#x - > restart next time.\n", MemInfo.WorkingSetSize)); 6057 //fprintf(stderr, "WorkingSetSize = %#x - > restart next time.\n", MemInfo.WorkingSetSize); 6058 g_fRestart = K_TRUE; 6059 } 6060 } 6061 } 6062 6063 6064 static void kwSandboxCleanup(PKWSANDBOX pSandbox) 6065 { 6066 PPEB pPeb = kwSandboxGetProcessEnvironmentBlock(); 6067 pPeb->ProcessParameters->CommandLine = pSandbox->SavedCommandLine; 6034 6068 } 6035 6069 … … 6115 6149 rcExit = 42 + 4; 6116 6150 6151 /* Clean up essential bits only, the rest is done after we've replied to kmk. */ 6117 6152 kwSandboxCleanup(&g_Sandbox); 6118 6153 } … … 6514 6549 cEnvVars, environ); 6515 6550 KW_LOG(("rcExit=%d\n", rcExit)); 6551 kwSandboxCleanupLate(&g_Sandbox); 6516 6552 } 6517 6553 … … 6661 6697 if ( rc == 0 6662 6698 && !g_fRestart) 6699 { 6700 kwSandboxCleanupLate(&g_Sandbox); 6663 6701 continue; 6702 } 6664 6703 } 6665 6704 else … … 6670 6709 rc = kwErrPrintfRc(-1, "Bogus message length: %u (%#x)\n", cbMsg, cbMsg); 6671 6710 } 6711 FlushFileBuffers(hPipe); 6712 CloseHandle(hPipe); 6672 6713 return rc > 0 ? 0 : 1; 6673 6714 }
Note:
See TracChangeset
for help on using the changeset viewer.