Revert "Fix tgkill retry logic" 18/318518/3
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 1 Oct 2024 10:45:24 +0000 (12:45 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 3 Oct 2024 08:19:56 +0000 (10:19 +0200)
This reverts commit f4e8020905f10fbcb12a06060aab132d2e447f3f.

Apparently there are some failures/crashes in other modules only if the
reverted commit is used. Reverting temporarily. To be investigated
later.

Change-Id: I9bd9e6b7acff8868609e2a91823ac1e73f87ef22

src/client/client-security-manager.cpp

index d1fe345c136a53db1fa1e5f0e0371faea96321ed..16a6ddbae728f0027302c6221612e3048c9d02ec 100644 (file)
@@ -677,25 +677,24 @@ static inline int security_manager_sync_threads_internal(const std::string &app_
             if (tids_sent_signals.find(existing_tid) == tids_sent_signals.end()) {
                 tids_sent_signals.insert(existing_tid);
                 add_managed_tid(existing_tid);
-
-                static constexpr unsigned ATTEMPTS = 2;
-                for (unsigned attempt = 0; attempt < ATTEMPTS; ++attempt) {
-                    // thread not managed yet, send signal
-                    if (Syscall::tgkill(own_pid, existing_tid, SIGSETXID) == 0)
-                        break;
-
+                // thread not managed yet, send signal
+                if (Syscall::tgkill(own_pid, existing_tid, SIGSETXID) < 0) {
                     auto err = errno;
                     if (EAGAIN == err) { // resource temporarily unavailable, trying again
-                        if (attempt == ATTEMPTS - 1) {
-                            LogWithErrno(err, "tgkill()");
-                            abort(); // too many attempts
-                        }
-
                         LogWarning("Received EAGAIN from tgkill, wait a bit & try again");
                         usleep(SLEEP_CONST);   // 10 ms
+                        if (Syscall::tgkill(own_pid, existing_tid, SIGSETXID) < 0) {
+                            err = errno;
+                            if (ESRCH == err) { // thread already gone - noop
+                                continue;
+                            } else {
+                                LogWithErrno(err, "tgkill()");
+                                abort();
+                            }
+                        }
+                    }
+                    if (ESRCH == err) { // thread already gone - noop
                         continue;
-                    } else if (ESRCH == err) { // thread already gone - noop
-                        break;
                     } else {
                         LogWithErrno(err, "tgkill()");
                         abort();