未验证 提交 8dbdb977 编写于 作者: 许云通 提交者: Gitee

[revert]

Signed-off-by: N许云通 <scorpion_xyt@outlook.com>
上级 f072744b
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// void RegisterFdHoldWatcher(int sock); void RegisterFdHoldWatcher(int sock);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -166,18 +166,18 @@ void ProcessFdHoldEvent(const WatcherHandle taskHandle, int fd, uint32_t *events ...@@ -166,18 +166,18 @@ void ProcessFdHoldEvent(const WatcherHandle taskHandle, int fd, uint32_t *events
*events = Event_Read; *events = Event_Read;
} }
// void RegisterFdHoldWatcher(int sock) void RegisterFdHoldWatcher(int sock)
// { {
// if (sock < 0) { if (sock < 0) {
// INIT_LOGE("Invalid fd holder socket"); INIT_LOGE("Invalid fd holder socket");
// return; return;
// } }
// WatcherHandle watcher = NULL; WatcherHandle watcher = NULL;
// LE_WatchInfo info = {}; LE_WatchInfo info = {};
// info.fd = sock; info.fd = sock;
// info.flags = 0; // WATCHER_ONCE; info.flags = 0; // WATCHER_ONCE;
// info.events = Event_Read; info.events = Event_Read;
// info.processEvent = ProcessFdHoldEvent; info.processEvent = ProcessFdHoldEvent;
// LE_StartWatcher(LE_GetDefaultLoop(), &watcher, &info, NULL); LE_StartWatcher(LE_GetDefaultLoop(), &watcher, &info, NULL);
// } }
...@@ -46,50 +46,50 @@ ...@@ -46,50 +46,50 @@
#include "fd_holder_internal.h" #include "fd_holder_internal.h"
#include "bootstage.h" #include "bootstage.h"
// static int FdHolderSockInit(void) static int FdHolderSockInit(void)
// { {
// int sock = -1; int sock = -1;
// int on = 1; int on = 1;
// int fdHolderBufferSize = FD_HOLDER_BUFFER_SIZE; // 4KiB int fdHolderBufferSize = FD_HOLDER_BUFFER_SIZE; // 4KiB
// sock = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); sock = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
// if (sock < 0) { if (sock < 0) {
// INIT_LOGE("Failed to create fd holder socket, err = %d", errno); INIT_LOGE("Failed to create fd holder socket, err = %d", errno);
// return -1; return -1;
// } }
// setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE, &fdHolderBufferSize, sizeof(fdHolderBufferSize)); setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE, &fdHolderBufferSize, sizeof(fdHolderBufferSize));
// setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
// if (access(INIT_HOLDER_SOCKET_PATH, F_OK) == 0) { if (access(INIT_HOLDER_SOCKET_PATH, F_OK) == 0) {
// INIT_LOGI("%s exist, remove it", INIT_HOLDER_SOCKET_PATH); INIT_LOGI("%s exist, remove it", INIT_HOLDER_SOCKET_PATH);
// unlink(INIT_HOLDER_SOCKET_PATH); unlink(INIT_HOLDER_SOCKET_PATH);
// } }
// struct sockaddr_un addr; struct sockaddr_un addr;
// addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
// if (strncpy_s(addr.sun_path, sizeof(addr.sun_path), if (strncpy_s(addr.sun_path, sizeof(addr.sun_path),
// INIT_HOLDER_SOCKET_PATH, strlen(INIT_HOLDER_SOCKET_PATH)) != 0) { INIT_HOLDER_SOCKET_PATH, strlen(INIT_HOLDER_SOCKET_PATH)) != 0) {
// INIT_LOGE("Failed to copy fd hoder socket path"); INIT_LOGE("Failed to copy fd hoder socket path");
// close(sock); close(sock);
// return -1; return -1;
// } }
// socklen_t len = (socklen_t)(offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path) + 1); socklen_t len = (socklen_t)(offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path) + 1);
// if (bind(sock, (struct sockaddr *)&addr, len) < 0) { if (bind(sock, (struct sockaddr *)&addr, len) < 0) {
// INIT_LOGE("Failed to binder fd folder socket %d", errno); INIT_LOGE("Failed to binder fd folder socket %d", errno);
// close(sock); close(sock);
// return -1; return -1;
// } }
// // Owned by root // Owned by root
// if (lchown(addr.sun_path, 0, 0)) { if (lchown(addr.sun_path, 0, 0)) {
// INIT_LOGW("Failed to change owner of fd holder socket, err = %d", errno); INIT_LOGW("Failed to change owner of fd holder socket, err = %d", errno);
// } }
// mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
// if (fchmodat(AT_FDCWD, addr.sun_path, mode, AT_SYMLINK_NOFOLLOW)) { if (fchmodat(AT_FDCWD, addr.sun_path, mode, AT_SYMLINK_NOFOLLOW)) {
// INIT_LOGW("Failed to change mode of fd holder socket, err = %d", errno); INIT_LOGW("Failed to change mode of fd holder socket, err = %d", errno);
// } }
// INIT_LOGI("Init fd holder socket done"); INIT_LOGI("Init fd holder socket done");
// return sock; return sock;
// } }
void SystemInit(void) void SystemInit(void)
{ {
...@@ -101,10 +101,10 @@ void SystemInit(void) ...@@ -101,10 +101,10 @@ void SystemInit(void)
// umask call always succeeds and return the previous mask value which is not needed here // umask call always succeeds and return the previous mask value which is not needed here
(void)umask(DEFAULT_UMASK_INIT); (void)umask(DEFAULT_UMASK_INIT);
MakeDirRecursive("/dev/unix/socket", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); MakeDirRecursive("/dev/unix/socket", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
// int sock = FdHolderSockInit(); int sock = FdHolderSockInit();
// if (sock >= 0) { if (sock >= 0) {
// RegisterFdHoldWatcher(sock); RegisterFdHoldWatcher(sock);
// } }
InitControlFd(); InitControlFd();
} }
......
...@@ -117,16 +117,16 @@ static void TestProcessTimer(const TimerHandle taskHandle, void *context) ...@@ -117,16 +117,16 @@ static void TestProcessTimer(const TimerHandle taskHandle, void *context)
count++; count++;
} }
// HWTEST_F(InitUnitTest, TestFdHoldService, TestSize.Level1) HWTEST_F(InitUnitTest, TestFdHoldService, TestSize.Level1)
// { {
// RegisterFdHoldWatcher(-1); RegisterFdHoldWatcher(-1);
// TimerHandle timer = nullptr; TimerHandle timer = nullptr;
// int ret = LE_CreateTimer(LE_GetDefaultLoop(), &timer, TestProcessTimer, nullptr); int ret = LE_CreateTimer(LE_GetDefaultLoop(), &timer, TestProcessTimer, nullptr);
// EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
// ret = LE_StartTimer(LE_GetDefaultLoop(), timer, 500, 2); ret = LE_StartTimer(LE_GetDefaultLoop(), timer, 500, 2);
// EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
// SystemRun(); SystemRun();
// } }
HWTEST_F(InitUnitTest, TestInitLog, TestSize.Level1) HWTEST_F(InitUnitTest, TestInitLog, TestSize.Level1)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册