-
Notifications
You must be signed in to change notification settings - Fork 52
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
Shared mem #28
Conversation
e9cd985
to
9136f31
Compare
👍 |
* | ||
* @return array An array of messages | ||
*/ | ||
public function receiveMessages() |
There was a problem hiding this comment.
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'?
There was a problem hiding this comment.
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.
6ecc684
to
507011c
Compare
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? |
2dc4bc2
to
f78c8f9
Compare
…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()`.
f78c8f9
to
fd77281
Compare
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). |
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 theshmop_
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 offendingshmid
value over to theipcrm
binary. My testing as of yet indicated no issues of this kind, but it's theoretically possible it can happen in some edge-cases.