Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c5cbd5

Browse files
committed
poll: introduce php_poll_msleep for win compat
1 parent 3916377 commit 9c5cbd5

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

‎main/poll/poll_backend_iocp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "php_poll_internal.h"
1616

17-
#ifdef _WIN32
17+
#ifdef PHP_WIN32
1818

1919
#include <winsock2.h>
2020
#include <ws2tcpip.h>
@@ -391,4 +391,4 @@ const php_poll_backend_ops php_poll_backend_iocp_ops = {
391391
.supports_et = true /* IOCP provides completion-based model which is naturally edge-triggered */
392392
};
393393

394-
#endif /* _WIN32 */
394+
#endif /* PHP_WIN32 */

‎main/poll/poll_backend_poll.c‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,30 @@ static bool poll_build_fds_callback(int fd, php_poll_fd_entry *entry, void *user
180180
return true;
181181
}
182182

183+
static void php_poll_msleep(int timeout_ms)
184+
{
185+
if (timeout_ms <= 0) {
186+
return;
187+
}
188+
189+
#ifdef PHP_WIN32
190+
Sleep(timeout_ms);
191+
#else
192+
struct timespec ts;
193+
ts.tv_sec = timeout_ms / 1000;
194+
ts.tv_nsec = (timeout_ms % 1000) * 1000000;
195+
nanosleep(&ts, NULL);
196+
#endif
197+
}
198+
183199
static int poll_backend_wait(php_poll_ctx *ctx, php_poll_event *events, int max_events, int timeout)
184200
{
185201
poll_backend_data_t *backend_data = (poll_backend_data_t *) ctx->backend_data;
186202

187203
int fd_count = php_poll_fd_table_count(backend_data->fd_table);
188204
if (fd_count == 0) {
189205
if (timeout > 0) {
190-
struct timespec ts;
191-
ts.tv_sec = timeout / 1000;
192-
ts.tv_nsec = (timeout % 1000) * 1000000;
193-
nanosleep(&ts, NULL);
206+
php_poll_msleep(timeout);
194207
}
195208
return 0;
196209
}

‎main/poll/poll_core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern const php_poll_backend_ops php_poll_backend_kqueue_ops;
2929
#ifdef HAVE_EVENT_PORTS
3030
extern const php_poll_backend_ops php_poll_backend_eventport_ops;
3131
#endif
32-
#ifdef _WIN32
32+
#ifdef PHP_WIN32
3333
extern const php_poll_backend_ops php_poll_backend_iocp_ops;
3434
#endif
3535
extern const php_poll_backend_ops php_poll_backend_poll_ops;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /