Throw exception when getting EMFILE errno 59/315159/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 26 Jul 2024 00:21:27 +0000 (09:21 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 26 Jul 2024 00:21:27 +0000 (09:21 +0900)
When the process cannot open a new file descriptior, the rpc-port
library throws an exception to create coredump file.

Change-Id: I5b9ebe83342cfca4511d4329676b67365d374e5d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/rpc-port/server-socket-internal.cc

index 3aca86ba60428390658fc7f4b64fedef082e06a7..80d4a25519d26e64d7d5e10a59bc6eae47cc9eb7 100644 (file)
@@ -58,6 +58,9 @@ ClientSocket* ServerSocket::Accept() {
   auto* addr_ptr = reinterpret_cast<struct sockaddr*>(&addr);
   int client_fd = accept(GetFd(), addr_ptr, &len);
   if (client_fd == -1) {
+    if (errno == EMFILE || errno == ENFILE)
+      THROW(-errno);
+
     _E("accept() is failed. errno(%d)", errno);  // LCOV_EXCL_LINE
     return nullptr;  // LCOV_EXCL_LINE
   }