2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef LAUNCHPAD_PROCESS_POOL_HYDRA_LOADER_CONTEXT_HH_
18 #define LAUNCHPAD_PROCESS_POOL_HYDRA_LOADER_CONTEXT_HH_
20 #include <sys/types.h>
24 #include "launchpad-process-pool/loader_context.hh"
28 class HydraLoaderContext : public LoaderContext {
30 class Builder : public LoaderContext::Builder {
32 operator LoaderContext*() override;
35 HydraLoaderContext(std::shared_ptr<LoaderInfo> loader_info, int loader_id,
36 pid_t caller_pid, bool activated,
37 std::shared_ptr<LoaderMount> loader_mount);
39 void Listen() override;
40 void Dispose() override;
41 pid_t Prepare() override;
43 pid_t GetHydraPid() const;
44 void SetHydraPid(pid_t hydra_pid);
47 void PrepareCandidateProcess();
48 void HandleHydraLoaderClientEvent(int condition);
49 void HandleHydraLoaderEvent();
50 void OnIOEventReceived(int fd, int condition) override;
53 bool hydra_prepared_ = false;
55 std::unique_ptr<ServerSocket> hydra_socket_;
56 std::unique_ptr<IOChannel> hydra_channel_;
57 std::unique_ptr<ClientSocket> client_socket_;
58 std::unique_ptr<IOChannel> client_channel_;
61 } // namespace launchpad
63 #endif // LAUNCHPAD_PROCESS_POOL_HYDRA_LOADER_CONTEXT_HH_