mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(handoff): a fork record stays only for the pid's current process
This commit is contained in:
1 parent
c16515fc49
commit
8fa2e65a42
1 file changed
+8
-4
@@ -154,10 +154,14 @@ static void ddh_forked_by(pid_t child, pid_t thread) {
|
||||
uint64_t seen = __atomic_load_n(slot, __ATOMIC_ACQUIRE);
|
||||
for (;;) {
|
||||
// A later child given the pid (this one reaped while its fork was being recorded) has
|
||||
// recorded itself already: its record stays. Start times compared within their 19 bits.
|
||||
if (seen && ddh_record_child(seen) == child && (seen & 0x80000) && (mine & 0x80000)) {
|
||||
uint64_t theirs = seen & 0x7ffff, ours = mine & 0x7ffff;
|
||||
if (theirs != ours && ((theirs - ours) & 0x7ffff) < 0x40000) return;
|
||||
// recorded itself already: its record stays. It is that child's only while the process that
|
||||
// has the pid now started when it says; any other record of the pid is an earlier child's.
|
||||
if (seen && ddh_record_child(seen) == child && (seen & 0x80000) && (mine & 0x80000) &&
|
||||
(seen & 0x7ffff) != (mine & 0x7ffff)) {
|
||||
saved = errno;
|
||||
long now = ddh_start_time(child);
|
||||
errno = saved;
|
||||
if (now > 0 && ((uint64_t)now & 0x7ffff) == (seen & 0x7ffff)) return;
|
||||
}
|
||||
if (__atomic_compare_exchange_n(slot, &seen, mine, 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user