Skip to content

Commit 17e4fa7

Browse files
committed
ftp: For single fd poll calls, use php_pollfd_for_ms
1 parent c329a71 commit 17e4fa7

1 file changed

Lines changed: 8 additions & 28 deletions

File tree

ext/ftp/ftp.c

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,9 @@ bool ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const cha
308308

309309
case SSL_ERROR_WANT_READ:
310310
case SSL_ERROR_WANT_WRITE: {
311-
php_pollfd p;
312-
int i;
311+
int i, events = (err == SSL_ERROR_WANT_READ) ? (POLLIN|POLLPRI) : POLLOUT;
313312

314-
p.fd = ftp->fd;
315-
p.events = (err == SSL_ERROR_WANT_READ) ? (POLLIN|POLLPRI) : POLLOUT;
316-
p.revents = 0;
317-
318-
i = php_poll2(&p, 1, 300);
313+
i = php_pollfd_for_ms(ftp->fd, events, 300);
319314

320315
retry = i > 0;
321316
}
@@ -1388,14 +1383,9 @@ static int single_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t size) {
13881383

13891384
case SSL_ERROR_WANT_READ:
13901385
case SSL_ERROR_WANT_CONNECT: {
1391-
php_pollfd p;
1392-
int i;
1393-
1394-
p.fd = fd;
1395-
p.events = POLLOUT;
1396-
p.revents = 0;
1386+
int i, events = POLLOUT;
13971387

1398-
i = php_poll2(&p, 1, 300);
1388+
i = php_pollfd_for_ms(fd, events, 300);
13991389

14001390
retry = i > 0;
14011391
}
@@ -1521,14 +1511,9 @@ static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
15211511

15221512
case SSL_ERROR_WANT_READ:
15231513
case SSL_ERROR_WANT_CONNECT: {
1524-
php_pollfd p;
1525-
int i;
1514+
int i, events = POLLIN|POLLPRI;
15261515

1527-
p.fd = fd;
1528-
p.events = POLLIN|POLLPRI;
1529-
p.revents = 0;
1530-
1531-
i = php_poll2(&p, 1, 300);
1516+
i = php_pollfd_for_ms(fd, events, 300);
15321517

15331518
retry = i > 0;
15341519
}
@@ -1825,14 +1810,9 @@ static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp)
18251810

18261811
case SSL_ERROR_WANT_READ:
18271812
case SSL_ERROR_WANT_WRITE: {
1828-
php_pollfd p;
1829-
int i;
1830-
1831-
p.fd = data->fd;
1832-
p.events = (err == SSL_ERROR_WANT_READ) ? (POLLIN|POLLPRI) : POLLOUT;
1833-
p.revents = 0;
1813+
int i, events = (err == SSL_ERROR_WANT_READ) ? (POLLIN|POLLPRI) : POLLOUT;
18341814

1835-
i = php_poll2(&p, 1, 300);
1815+
i = php_pollfd_for_ms(data->fd, events, 300);
18361816

18371817
retry = i > 0;
18381818
}

0 commit comments

Comments
 (0)