libcamera: ipc_unixsocket: Use UniqueFD for a file descriptor

IPCUnixSocket::create() creates two file descriptors. One of
them is stored in IPCUnixSocket and the other is returned to a
caller. This clarifies the ownership using UniqueFD.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Hirokazu Honda 2021-06-10 16:50:25 +09:00 committed by Laurent Pinchart
parent edd70612e5
commit 9143668887
6 changed files with 49 additions and 44 deletions

View file

@ -12,6 +12,7 @@
#include <vector>
#include <libcamera/base/signal.h>
#include <libcamera/base/unique_fd.h>
namespace libcamera {
@ -28,8 +29,8 @@ public:
IPCUnixSocket();
~IPCUnixSocket();
int create();
int bind(int fd);
UniqueFD create();
int bind(UniqueFD fd);
void close();
bool isBound() const;
@ -49,7 +50,7 @@ private:
void dataNotifier();
int fd_;
UniqueFD fd_;
bool headerReceived_;
struct Header header_;
EventNotifier *notifier_;