Use unix sockets instead of pipes for posix daemon. (#10766)
Unlike pipes, unix sockets provide bi-directional communication with each connected client. - No need to generate a unique uuid per client anymore. - The client doesn't have to create its own pipe anymore. - Since there is no risk of multiple client's writes getting mixed up, messages don't need to fit in a single write anymore, removing the limit on command length. - Since the server can detect a connection closing, the client no longer needs to handle signals. When the client is killed, the connection is automatically closed, which will cause the server to kill the related px4 thread. Since this does not rely on handling signals and the client sending an additional message, this is much more reliable. - Client is no longer a singleton. - The protocol is simplified. Standard output is directly written to the socket back to the client, without wrapping it in any protocol message. - Because of the simple protocol, one could now even use netcat to run a px4 command: $ echo hello | netcat -UN /tmp/px4-sock-0 Also removes a few race conditions.
Showing
- platforms/posix/src/main.cpp 0 additions, 2 deletionsplatforms/posix/src/main.cpp
- platforms/posix/src/px4_daemon/CMakeLists.txt 1 addition, 1 deletionplatforms/posix/src/px4_daemon/CMakeLists.txt
- platforms/posix/src/px4_daemon/client.cpp 80 additions, 234 deletionsplatforms/posix/src/px4_daemon/client.cpp
- platforms/posix/src/px4_daemon/client.h 15 additions, 31 deletionsplatforms/posix/src/px4_daemon/client.h
- platforms/posix/src/px4_daemon/server.cpp 128 additions, 209 deletionsplatforms/posix/src/px4_daemon/server.cpp
- platforms/posix/src/px4_daemon/server.h 14 additions, 34 deletionsplatforms/posix/src/px4_daemon/server.h
- platforms/posix/src/px4_daemon/server_io.cpp 5 additions, 25 deletionsplatforms/posix/src/px4_daemon/server_io.cpp
- platforms/posix/src/px4_daemon/sock_protocol.cpp 7 additions, 31 deletionsplatforms/posix/src/px4_daemon/sock_protocol.cpp
- platforms/posix/src/px4_daemon/sock_protocol.h 4 additions, 55 deletionsplatforms/posix/src/px4_daemon/sock_protocol.h
Loading
Please register or sign in to comment