Skip to content

Commit dfd3d09

Browse files
committed
Simplify code in SharedMemoryBase() ctor.
Add missed alignment in remapFile().
1 parent 62ca546 commit dfd3d09

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/common/isc_sync.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,13 +1314,10 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject
13141314

13151315
if (length)
13161316
{
1317-
sh_mem_increment = FB_ALIGN(length, getSystemPageSize(&statusVector));
1317+
sh_mem_increment = length = FB_ALIGN(length, getSystemPageSize(&statusVector));
13181318

13191319
if (statusVector.hasData())
13201320
status_exception::raise(&statusVector);
1321-
1322-
if (length < sh_mem_increment)
1323-
length = sh_mem_increment;
13241321
}
13251322

13261323
const bool trunc_flag = (length != 0);
@@ -1649,13 +1646,10 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject
16491646
LocalStatus ls;
16501647
CheckStatusWrapper statusVector(&ls);
16511648

1652-
sh_mem_increment = FB_ALIGN(length, getSystemPageSize(&statusVector));
1649+
sh_mem_increment = length = FB_ALIGN(length, getSystemPageSize(&statusVector));
16531650

16541651
if (statusVector.hasData())
16551652
status_exception::raise(&statusVector);
1656-
1657-
if (length < sh_mem_increment)
1658-
length = sh_mem_increment;
16591653
}
16601654

16611655
// retry to attach to mmapped file if the process initializing dies during initialization.
@@ -2525,6 +2519,8 @@ bool SharedMemoryBase::remapFile(CheckStatusWrapper* statusVector, ULONG new_len
25252519

25262520
if (flag)
25272521
{
2522+
new_length = FB_ALIGN(new_length, getSystemPageSize(statusVector));
2523+
25282524
FB_UNUSED(os_utils::ftruncate(mainLock->getFd(), new_length));
25292525

25302526
if (new_length > sh_mem_length_mapped)
@@ -2581,6 +2577,8 @@ bool SharedMemoryBase::remapFile(CheckStatusWrapper* statusVector,
25812577

25822578
if (flag)
25832579
{
2580+
new_length = FB_ALIGN(new_length, getSystemPageSize(statusVector));
2581+
25842582
LARGE_INTEGER offset;
25852583
offset.QuadPart = new_length;
25862584

0 commit comments

Comments
 (0)