Skip to content

Commit fe716b9

Browse files
committed
php#53: Optimize async socket timeout tests for faster execution
- Reduce UDP timeout from 2s to 0.2s in test 030 - Reduce TCP timeout from 1s to 0.2s in test 031 - Remove timing measurements and elapsed time checks - Simplify timeout validation to only check timed_out flag - Reduce client delay from 2s to 0.5s in TCP tes
1 parent 50cf37c commit fe716b9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

main/network_async.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ZEND_API int network_async_await_stream_socket(php_netstream_data_t *netdata, as
288288
return -1;
289289
}
290290

291-
// Initialize result counter to 0 (will be set to 1 on event)
291+
// Initialize result counter to 0 (timeout by default)
292292
ZVAL_LONG(&coroutine->waker->result, 0);
293293

294294
// Suspend until event or timeout
@@ -303,7 +303,11 @@ ZEND_API int network_async_await_stream_socket(php_netstream_data_t *netdata, as
303303
const int result = Z_LVAL(coroutine->waker->result);
304304
zend_async_waker_clean(coroutine);
305305

306-
return result > 0 ? 1 : 0;
306+
// Return appropriate values:
307+
// 1 = socket event occurred (success)
308+
// 0 = timeout occurred
309+
// -1 = error (handled above for exceptions)
310+
return result;
307311
}
308312
///////////////////////////////////////////////////////////////
309313
/// Poll2 Emulation for Async Context

main/streams/xp_socket.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,8 @@ static inline int sock_async_poll(php_netstream_data_t *sock, async_poll_event p
365365

366366
if (UNEXPECTED(poll_result <= 0)) {
367367
if (poll_result == 0 && timeout) {
368-
php_error_docref(NULL, E_WARNING, "Socket operation timed out after %ld.%06ld seconds",
369-
(long)timeout->tv_sec, (long)timeout->tv_usec);
370-
371368
sock->timeout_event = true;
372-
return -1;
373369
}
374-
375370
return poll_result;
376371
}
377372

0 commit comments

Comments
 (0)