Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared mem #28

Merged
merged 1 commit into from
May 18, 2015
Merged

Conversation

MattJaniszewski
Copy link
Contributor

I ran into a limit when the FIFO pipe would get full (> ~62k of data), and cause the child processes to block until the pipe was cleared (e.g., by running the cat command in the appropriate FIFO handle on the file system). The use of the shmop_ functions seemed like a good alternative.

In the PR, I added a unit test which re-creates the problem that kept the original version from working on a typical Linux system.

One thing I will note is that while I did all the due-diligence I could with the shmop_ functions, I had to end up using @shmop_open with the error suppressor operator twice, to test for the presence for an existing memory segment. It's not ideal, but seemed like the only way.

A decent way to test that there are no left-over open memory segments is to run ipcs -m on the Linux system. You can then pass any offending shmid value over to the ipcrm binary. My testing as of yet indicated no issues of this kind, but it's theoretically possible it can happen in some edge-cases.

@seyfer
Copy link

seyfer commented Apr 19, 2015

👍

@githoober
Copy link

@MattJaniszewski: 👍

*
* @return array An array of messages
*/
public function receiveMessages()

Choose a reason for hiding this comment

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

In what cases will the result value contain more then one message?

Shouldn't this method be rather called 'receive' as the opposite of 'send'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Oleg. I took a look again at this code, and realized that this method wasn't actually working as advertised. I think that I fixed the logic now, so take another look when you can.

@MattJaniszewski MattJaniszewski force-pushed the shared-mem branch 2 times, most recently from 6ecc684 to 507011c Compare April 20, 2015 17:42
@kriswallsmith
Copy link
Owner

Would you mind removing the PSR-2 commit (or moving it to another pull request) so that this pull request is limited to the shared memory change?

@MattJaniszewski MattJaniszewski force-pushed the shared-mem branch 2 times, most recently from 2dc4bc2 to f78c8f9 Compare April 22, 2015 20:31
…the PHP shared memory subsystem to establish communication between parent and child processes after they are forked.

Consolidated the `receiveOne()` and `receiveMany()` methods to one method: `receiveMessages()`. The entire array of messages being sent will be serialized, rather than separating individual serialized message objects by newlines, and writing those to shared memory. This makes unserializing the messages inside `receiveMessages()` a lot easier, and doesn't require special cases to determine differences between object separators and "real" newlines.

Added unit tests which cover the cases which made this particular fix necessary.

Removed pass-by-reference operators for the arguments passed to `register_shutdown_function()`.
@MattJaniszewski
Copy link
Contributor Author

I rebased this branch, and removed all the un-related modifications. I created separate branches for them, and I'll create the pull requests later (so they will end up being fast-forward merges).

@kriswallsmith kriswallsmith merged commit fd77281 into kriswallsmith:master May 18, 2015
@MattJaniszewski MattJaniszewski deleted the shared-mem branch May 18, 2015 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants