Commit d37995d
committed
* Fix race condition in process event handling by using PID-based shared events
Problem: The async extension created separate event objects for each
process monitoring request, leading to multiple waitpid() calls for the
same PID. This caused race conditions where one waitpid() would succeed
and subsequent calls would fail with ECHILD, resulting in "Cannot resume
a coroutine that has not been suspended" errors.
Solution: Modified process event system to use PID as hash key instead
of event object address. Now libuv_new_process_event() returns existing
event for a PID (with incremented ref count) or creates new one if none
exists. This ensures only one waitpid() call per process.
Changes:
- libuv_new_process_event(): Added PID-based lookup and ref counting
- libuv_handle_process_events(): Updated to use PID keys for verification
- libuv_remove_process_event(): Modified to use PID keys and check ref count
- libuv_add_process_event(): Simplified since hash insertion now handled by new_process_event
Fixes intermittent failures in stream_select_remote_disconnect.phpt test.1 parent 6d48411 commit d37995d
1 file changed
+36
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
990 | 994 | | |
991 | 995 | | |
992 | | - | |
| 996 | + | |
993 | 997 | | |
994 | 998 | | |
995 | 999 | | |
996 | 1000 | | |
997 | | - | |
998 | 1001 | | |
999 | 1002 | | |
1000 | 1003 | | |
| |||
1051 | 1054 | | |
1052 | 1055 | | |
1053 | 1056 | | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1061 | 1060 | | |
1062 | 1061 | | |
1063 | 1062 | | |
| |||
1069 | 1068 | | |
1070 | 1069 | | |
1071 | 1070 | | |
1072 | | - | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1073 | 1079 | | |
1074 | 1080 | | |
1075 | 1081 | | |
| |||
1530 | 1536 | | |
1531 | 1537 | | |
1532 | 1538 | | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1533 | 1556 | | |
1534 | 1557 | | |
1535 | 1558 | | |
| |||
1543 | 1566 | | |
1544 | 1567 | | |
1545 | 1568 | | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1546 | 1572 | | |
1547 | 1573 | | |
1548 | 1574 | | |
| |||
0 commit comments