Closed Camerooooon closed 2 years ago
The solution that I decided to use was to replace most of the references to the Daemon
with references to an Arc<Mutex<Daemon>>
which is what I would say is a "wrapper struct" that "surrounds" the daemon. This struct controls which thread is allowed to read and write to the object (in this case the daemon). A thread can request to read/write data by performing a "lock" on the data which basically says to whatever thread is requesting the data that it needs to wait for the main thread to stop using the data (in this case if the main thread is utilizing the data the socket thread will wait for the request to finish before proceeding thereby holding up the socket thread which is not a problem since our acs client can be patient).
I've implemented the command listening and parsing. You can now use socat to broadcast 0|test hello
following the protocol outlines.
Ok, this PR is almost complete. It needs a LOT of reviews there are so many situations where it can break and it's quite unstable.
its still a draft pr cant review
I'm going to make acs monit broadcast and listen for the hello packet before merge.
We can add more packets in later prs. Also I need to add more error handling.
Sounds good, great work!
I see;
Arc is a smart pointer that let's you safely share a value between multiple threads.
Mutex is a wrapper over another type, which allows safe mutability across threads. - Piotr Sarnacki
So basically, remove the run method from daemon, replace it with a run function that accepts a safe mutable version of the daemon. That's cool
This looks very close to being done, if not already done. Anything else you think would be good to add?
This looks very close to being done, if not already done. Anything else you think would be good to add?
It needs to be stabilized lots of unhandled exceptions.
Almost done, just fixed a major bug!
Looks like we are go for review @JakeRoggenbuck and @Shuzhengz! The daemon hooking is working, please re-review then merge this!
Looks like we are go for review @JakeRoggenbuck and @Shuzhengz! The daemon hooking is working, please re-review then merge this!
Awesome!
What is a good way to test the sending to the socket?
Cargo monit attempts to send the hello packet. It will then print out the response to std out ( you will need to scroll up because it gets pushed away by the TUI ) you can test by reading that response. Additionally you can use socat to manually attach to the sock and send packets yourself.
Tested, everything seems good.
Yay! very well done!