prevent EXCEPTION_INT_DIVIDE_BY_ZERO

- when server is shutting down via ctrl+c in Sentinel mode - prevent
  crash in EnsureMEmoryIsMapped
- fixes #62
This commit is contained in:
tporadowski
2020-06-17 21:42:47 +02:00
parent 4366d7e836
commit 7ce82ac723
+6
View File
@@ -29,6 +29,12 @@ namespace Globals
/* This function is used to force the VEH on the entire size of the buffer length,
* in the event that the buffer crosses the memory page boundaries */
void EnsureMemoryIsMapped(const void *buffer, size_t size) {
//[tporadowski/#62] when this is called from main process - Globals::pageSize is not initialized,
// so prevent EXCEPTION_INT_DIVIDE_BY_ZERO
if (Globals::pageSize == 0) {
return;
}
char* pFirstByte = (char*) buffer;
char* pLastByte = (char*) buffer + size - 1;
char* pFirstPage = pFirstByte - ((size_t) pFirstByte % Globals::pageSize);