summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-06-10 16:50:25 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:03 +0200
commit91436688874a2450c7da22527c59e34c2053b9ef (patch)
treed7220d238db08c90ab37f990a60414483a77d6cf /utils
parentedd70612e520f742600ce997f3b4ab0e0d9236c8 (diff)
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>
Diffstat (limited to 'utils')
-rw-r--r--utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl13
1 files changed, 7 insertions, 6 deletions
diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl
index 764e7a3a..b65dc4cf 100644
--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl
+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl
@@ -27,8 +27,9 @@
#include <libcamera/logging.h>
#include <libcamera/base/event_dispatcher.h>
-#include <libcamera/base/thread.h>
#include <libcamera/base/log.h>
+#include <libcamera/base/thread.h>
+#include <libcamera/base/unique_fd.h>
#include "libcamera/internal/camera_sensor.h"
#include "libcamera/internal/control_serializer.h"
@@ -122,9 +123,9 @@ public:
}
}
- int init(std::unique_ptr<IPAModule> &ipam, int socketfd)
+ int init(std::unique_ptr<IPAModule> &ipam, UniqueFD socketfd)
{
- if (socket_.bind(socketfd) < 0) {
+ if (socket_.bind(std::move(socketfd)) < 0) {
LOG({{proxy_worker_name}}, Error)
<< "IPC socket binding failed";
return EXIT_FAILURE;
@@ -203,10 +204,10 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- int fd = std::stoi(argv[2]);
+ UniqueFD fd(std::stoi(argv[2]));
LOG({{proxy_worker_name}}, Info)
<< "Starting worker for IPA module " << argv[1]
- << " with IPC fd = " << fd;
+ << " with IPC fd = " << fd.get();
std::unique_ptr<IPAModule> ipam = std::make_unique<IPAModule>(argv[1]);
if (!ipam->isValid() || !ipam->load()) {
@@ -228,7 +229,7 @@ int main(int argc, char **argv)
}
{{proxy_worker_name}} proxyWorker;
- int ret = proxyWorker.init(ipam, fd);
+ int ret = proxyWorker.init(ipam, std::move(fd));
if (ret < 0) {
LOG({{proxy_worker_name}}, Error)
<< "Failed to initialize proxy worker";