Skip to content

Commit 1682685

Browse files
committed
Use @twose's suggestion to circumvent GCC bug 69602
1 parent 45b168d commit 1682685

File tree

5 files changed

+13
-59
lines changed

5 files changed

+13
-59
lines changed

ext/sockets/sockets.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,20 +1045,7 @@ PHP_FUNCTION(socket_read)
10451045
if (retval == -1) {
10461046
/* if the socket is in non-blocking mode and there's no data to read,
10471047
don't output any error, as this is a normal situation, and not an error */
1048-
1049-
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
1050-
#if defined(__GNUC__) && !defined(__clang__)
1051-
#pragma GCC diagnostic push
1052-
#pragma GCC diagnostic ignored "-Wlogical-op"
1053-
#endif
1054-
if (errno == EAGAIN
1055-
#ifdef EWOULDBLOCK
1056-
|| errno == EWOULDBLOCK
1057-
#endif
1058-
) {
1059-
#if defined(__GNUC__) && !defined(__clang__)
1060-
#pragma GCC diagnostic pop
1061-
#endif
1048+
if (IS_TRANSIENT_ERROR(errno)) {
10621049
php_sock->error = errno;
10631050
SOCKETS_G(last_error) = errno;
10641051
} else {

main/php_network.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
# define EWOULDBLOCK EAGAIN
5050
#endif
5151

52+
/* This is a work around for GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
53+
#if EAGAIN != EWOULDBLOCK
54+
# define IS_TRANSIENT_ERROR(err) (err == EAGAIN || err == EWOULDBLOCK)
55+
#else
56+
# define IS_TRANSIENT_ERROR(err) (err == EAGAIN)
57+
#endif
58+
5259
#ifdef PHP_WIN32
5360
#define php_socket_errno() WSAGetLastError()
5461
#else

main/streams/plain_wrapper.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,7 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
351351
ssize_t bytes_written = write(data->fd, buf, count);
352352
#endif
353353
if (bytes_written < 0) {
354-
355-
#if defined(__GNUC__) && !defined(__clang__)
356-
#pragma GCC diagnostic push
357-
#pragma GCC diagnostic ignored "-Wlogical-op"
358-
#endif
359-
if (errno == EWOULDBLOCK || errno == EAGAIN) {
360-
#if defined(__GNUC__) && !defined(__clang__)
361-
#pragma GCC diagnostic pop
362-
#endif
354+
if (IS_TRANSIENT_ERROR(errno)) {
363355
return 0;
364356
}
365357
if (errno == EINTR) {
@@ -428,15 +420,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
428420
}
429421

430422
if (ret < 0) {
431-
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
432-
#if defined(__GNUC__) && !defined(__clang__)
433-
#pragma GCC diagnostic push
434-
#pragma GCC diagnostic ignored "-Wlogical-op"
435-
#endif
436-
if (errno == EWOULDBLOCK || errno == EAGAIN) {
437-
#if defined(__GNUC__) && !defined(__clang__)
438-
#pragma GCC diagnostic pop
439-
#endif
423+
if (IS_TRANSIENT_ERROR(errno)) {
440424
/* Not an error. */
441425
ret = 0;
442426
} else if (errno == EINTR) {

main/streams/xp_socket.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,7 @@ static ssize_t php_sockop_write(php_stream *stream, const char *buf, size_t coun
7676
char *estr;
7777
int err = php_socket_errno();
7878

79-
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
80-
#if defined(__GNUC__) && !defined(__clang__)
81-
#pragma GCC diagnostic push
82-
#pragma GCC diagnostic ignored "-Wlogical-op"
83-
#endif
84-
if (err == EWOULDBLOCK || err == EAGAIN) {
85-
#if defined(__GNUC__) && !defined(__clang__)
86-
#pragma GCC diagnostic pop
87-
#endif
79+
if (IS_TRANSIENT_ERROR(err)) {
8880
if (sock->is_blocked) {
8981
int retval;
9082

@@ -175,15 +167,7 @@ static ssize_t php_sockop_read(php_stream *stream, char *buf, size_t count)
175167
err = php_socket_errno();
176168

177169
if (nr_bytes < 0) {
178-
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
179-
#if defined(__GNUC__) && !defined(__clang__)
180-
#pragma GCC diagnostic push
181-
#pragma GCC diagnostic ignored "-Wlogical-op"
182-
#endif
183-
if (err == EAGAIN || err == EWOULDBLOCK) {
184-
#if defined(__GNUC__) && !defined(__clang__)
185-
#pragma GCC diagnostic pop
186-
#endif
170+
if (IS_TRANSIENT_ERROR(err)) {
187171
nr_bytes = 0;
188172
} else {
189173
stream->eof = 1;

sapi/fpm/fpm/fpm_stdio.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,7 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
166166
stdio_read:
167167
in_buf = read(fd, buf, max_buf_size - 1);
168168
if (in_buf <= 0) { /* no data */
169-
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
170-
#if defined(__GNUC__) && !defined(__clang__)
171-
#pragma GCC diagnostic push
172-
#pragma GCC diagnostic ignored "-Wlogical-op"
173-
#endif
174-
if (in_buf == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
175-
#if defined(__GNUC__) && !defined(__clang__)
176-
#pragma GCC diagnostic pop
177-
#endif
169+
if (in_buf == 0 || !IS_TRANSIENT_ERROR(errno)) {
178170
/* pipe is closed or error */
179171
read_fail = (in_buf < 0) ? in_buf : 1;
180172
}

0 commit comments

Comments
 (0)