Skip to content

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented May 27, 2022

There is not much point in having two distinct file mappings; since the
info mapping is very small and of fixed size, we can put it at the
beginning of a single mapping. Besides the obvious resource savings,
that also simplifies the error handling.

There is not much point in having two distinct file mappings; since the
info mapping is very small and of fixed size, we can put it at the
beginning of a single mapping.  Besides the obvious resource savings,
that also simplifies the error handling.
@cmb69
Copy link
Member Author

cmb69 commented Jun 7, 2022

If there are no objections, I'll merge this by the end of the week.

@@ -706,7 +690,7 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags)
return (void*)-1;
}

shm->addr = MapViewOfFileEx(shm->segment, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
shm->addr = shm->descriptor + sizeof(shm->descriptor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling here is wrong, if (NULL == shm->addr) { would be comparing shm->descriptor + sizeof(shm->descriptor); against NULL

As a result, this would start returning non-null.

At a quick glance, the rest of the pointer operations seemed normal

I suspect some part of this change is related to krakjoe/apcu#445 - apcu calls shmat in 3 places https://github.com/krakjoe/apcu/blob/v5.1.22/apc_shm.c#L72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants