Skip to content

Commit 63a3af4

Browse files
committed
poll: use php_pollfd instead of struct pollfd
1 parent ee01407 commit 63a3af4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

main/poll/poll_backend_poll.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
typedef struct {
1818
php_poll_fd_table *fd_table;
19-
struct pollfd *temp_fds;
19+
php_pollfd *temp_fds;
2020
int temp_fds_capacity;
2121
} poll_backend_data_t;
2222

@@ -76,7 +76,7 @@ static zend_result poll_backend_init(php_poll_ctx *ctx)
7676
return FAILURE;
7777
}
7878

79-
data->temp_fds = php_poll_calloc(initial_capacity, sizeof(struct pollfd), ctx->persistent);
79+
data->temp_fds = php_poll_calloc(initial_capacity, sizeof(php_pollfd), ctx->persistent);
8080
if (!data->temp_fds) {
8181
php_poll_fd_table_cleanup(data->fd_table);
8282
pefree(data, ctx->persistent);
@@ -160,13 +160,13 @@ static zend_result poll_backend_remove(php_poll_ctx *ctx, int fd)
160160
return SUCCESS;
161161
}
162162

163-
/* Context for building pollfd array */
163+
/* Context for building php_pollfd array */
164164
typedef struct {
165-
struct pollfd *fds;
165+
php_pollfd *fds;
166166
int index;
167167
} poll_build_context;
168168

169-
/* Callback to build pollfd array from fd_table */
169+
/* Callback to build php_pollfd array from fd_table */
170170
static bool poll_build_fds_callback(int fd, php_poll_fd_entry *entry, void *user_data)
171171
{
172172
poll_build_context *ctx = (poll_build_context *) user_data;
@@ -197,8 +197,8 @@ static int poll_backend_wait(php_poll_ctx *ctx, php_poll_event *events, int max_
197197

198198
/* Ensure temp_fds array is large enough */
199199
if (fd_count > backend_data->temp_fds_capacity) {
200-
struct pollfd *new_fds = php_poll_realloc(
201-
backend_data->temp_fds, fd_count * sizeof(struct pollfd), ctx->persistent);
200+
php_pollfd *new_fds = php_poll_realloc(
201+
backend_data->temp_fds, fd_count * sizeof(php_pollfd), ctx->persistent);
202202
if (!new_fds) {
203203
php_poll_set_error(ctx, PHP_POLL_ERR_NOMEM);
204204
return -1;
@@ -207,7 +207,7 @@ static int poll_backend_wait(php_poll_ctx *ctx, php_poll_event *events, int max_
207207
backend_data->temp_fds_capacity = fd_count;
208208
}
209209

210-
/* Build pollfd array from fd_table */
210+
/* Build php_pollfd array from fd_table */
211211
poll_build_context build_ctx = { .fds = backend_data->temp_fds, .index = 0 };
212212
php_poll_fd_table_foreach(backend_data->fd_table, poll_build_fds_callback, &build_ctx);
213213

@@ -218,10 +218,10 @@ static int poll_backend_wait(php_poll_ctx *ctx, php_poll_event *events, int max_
218218
return nfds; /* Return 0 for timeout, -1 for error */
219219
}
220220

221-
/* Process results - iterate through pollfd array directly */
221+
/* Process results - iterate through php_pollfd array directly */
222222
int event_count = 0;
223223
for (int i = 0; i < fd_count && event_count < max_events; i++) {
224-
struct pollfd *pfd = &backend_data->temp_fds[i];
224+
php_pollfd *pfd = &backend_data->temp_fds[i];
225225

226226
if (pfd->revents != 0) {
227227
php_poll_fd_entry *entry = php_poll_fd_table_find(backend_data->fd_table, pfd->fd);

0 commit comments

Comments
 (0)