Comments (10)
I took a quick look and I think I know what's happening:
- XPC will report events to the handler which was registered here: https://github.com/sandeepmistry/node-xpc-connection/blob/master/src/XpcConnection.cpp#L52
- And it will do so in the dispatch queue which was setup here: https://github.com/sandeepmistry/node-xpc-connection/blob/master/src/XpcConnection.cpp#L49
- That means that handleEvent runs in a thread other than the loop thread: https://github.com/sandeepmistry/node-xpc-connection/blob/master/src/XpcConnection.cpp#L64
- handleEvent calls uv_queue_work, which is not thread-safe, so things will eventually blow up
Here is a suggestion:
- Use a thread-safe queue (an array with a lock will do) and store the events there from handleEvent
- Use an uv_async_t handle to process the queue in the loop thread: uv_async_send is thread safe: http://docs.libuv.org/en/latest/async.html#c.uv_async_send
- Profit?
Hope that helps!
from node-xpc-connection.
@vielmetti this might also be useful for getting a stack trace: https://github.com/ddopson/node-segfault-handler
from node-xpc-connection.
Thanks @saghul that is tremendously helpful.
from node-xpc-connection.
@saghul thanks for the explanation and suggestion!
Would you mind quickly reviewing 2f7734b before I merge into master?
from node-xpc-connection.
Looks good!
On Mar 31, 2015 2:52 AM, "Sandeep Mistry" [email protected] wrote:
@saghul https://github.com/saghul thanks for the explanation and
suggestion!Would you mind quickly reviewing 2f7734b
2f7734b
before I merge into master?—
Reply to this email directly or view it on GitHub
#7 (comment)
.
from node-xpc-connection.
Thanks! I'm putting together a test environment with this code, the new noble release, and support for the new Sensortag 2 - hope to exercise this soon in the same way that I did before.
from node-xpc-connection.
I just had another look. I initially thought about having a mutex + queue + async handle per XPC connection. Alternatively, you can also have a global async handle, which you initialize only once with uv_once: http://docs.libuv.org/en/v1.x/threading.html?highlight=uv_once#once-only-initialization
Not sure about the performance impact of either, but both should work.
from node-xpc-connection.
@saghul good suggestion, I've made changes to have one mutex + queue + async per XPC connection: 4be4f4a
Would you mind quickly reviewing again?
from node-xpc-connection.
@vielmetti I've published a new version (0.1.3) to npm, with the changes @saghul suggested.
@saghul thanks again for your help!
from node-xpc-connection.
Glad to help!
On Apr 5, 2015 15:27, "Sandeep Mistry" [email protected] wrote:
@vielmetti https://github.com/vielmetti I've published a new version
(0.1.3) to npm, with the changes @saghul https://github.com/saghul
suggested.@saghul https://github.com/saghul thanks again for your help!
—
Reply to this email directly or view it on GitHub
#7 (comment)
.
from node-xpc-connection.
Related Issues (20)
- Node v4 node-gyp rebuild fails HOT 2
- Clone of this repo fails to build Node 0.12 / 4.2.3, node-gyp 3.2.1, gcc HOT 2
- Error when installing xpc-connection on OSX El Capitan HOT 1
- Build Failure with node v6 HOT 5
- nwjs crash when require('noble') HOT 3
- Keeps process open HOT 1
- npm install compiler errors HOT 4
- node version error when working with electron HOT 4
- JXCore fails to run Noble HOT 1
- xpc-connection install issue on mac HOT 1
- nan dependency HOT 1
- symbolic link pointing to itself OSX 10.12.6 HOT 1
- Module installation fails on Mac (macOS 10.13.4) after upgrade to node v10.0.0 and npm v6.0.0 HOT 23
- xpc-connection issue HOT 1
- Install fails on macOS 10.14 and node 6 HOT 4
- Install fails on OSX node v11.1.0 HOT 1
- xpc-connection refuses to install HOT 12
- Fails to build Mac OS HOT 1
- 0.1.4 build fails when building for nw 0.8.6 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-xpc-connection.