summaryrefslogtreecommitdiffstats
path: root/2707.patch
blob: 4614be29339856807840e7421225c1f6961968cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
From b7514a7615b01aa20e0be73f7e13655a68fd61ea Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 23 Jul 2019 14:37:46 +0200
Subject: [PATCH] fix for stream changes in 7.4.0beta1

---
 swoole_runtime.cc                      | 17 +++++++++++++++++
 thirdparty/php/streams/plain_wrapper.c | 21 +++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/swoole_runtime.cc b/swoole_runtime.cc
index eb6664a61..dc0fb9ad3 100644
--- a/swoole_runtime.cc
+++ b/swoole_runtime.cc
@@ -38,8 +38,13 @@ static PHP_FUNCTION(swoole_user_func_handler);
 }
 
 static int socket_set_option(php_stream *stream, int option, int value, void *ptrparam);
+#if PHP_VERSION_ID < 70400
 static size_t socket_read(php_stream *stream, char *buf, size_t count);
 static size_t socket_write(php_stream *stream, const char *buf, size_t count);
+#else
+static ssize_t socket_read(php_stream *stream, char *buf, size_t count);
+static ssize_t socket_write(php_stream *stream, const char *buf, size_t count);
+#endif
 static int socket_flush(php_stream *stream);
 static int socket_close(php_stream *stream, int close_handle);
 static int socket_stat(php_stream *stream, php_stream_statbuf *ssb);
@@ -259,7 +264,11 @@ static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *po
     return host;
 }
 
+#if PHP_VERSION_ID < 70400
 static size_t socket_write(php_stream *stream, const char *buf, size_t count)
+#else
+static ssize_t socket_write(php_stream *stream, const char *buf, size_t count)
+#endif
 {
     php_swoole_netstream_data_t *abstract = (php_swoole_netstream_data_t *) stream->abstract;
     if (UNEXPECTED(!abstract))
@@ -277,15 +286,21 @@ static size_t socket_write(php_stream *stream, const char *buf, size_t count)
     {
         php_stream_notify_progress_increment(PHP_STREAM_CONTEXT(stream), didwrite, 0);
     }
+#if PHP_VERSION_ID < 70400
     if (didwrite < 0)
     {
         didwrite = 0;
     }
+#endif
 
     return didwrite;
 }
 
+#if PHP_VERSION_ID < 70400
 static size_t socket_read(php_stream *stream, char *buf, size_t count)
+#else
+static ssize_t socket_read(php_stream *stream, char *buf, size_t count)
+#endif
 {
     php_swoole_netstream_data_t *abstract = (php_swoole_netstream_data_t *) stream->abstract;
     if (UNEXPECTED(!abstract))
@@ -309,10 +324,12 @@ static size_t socket_read(php_stream *stream, char *buf, size_t count)
         php_stream_notify_progress_increment(PHP_STREAM_CONTEXT(stream), nr_bytes, 0);
     }
 
+#if PHP_VERSION_ID < 70400
     if (nr_bytes < 0)
     {
         nr_bytes = 0;
     }
+#endif
 
     return nr_bytes;
 }
diff --git a/thirdparty/php/streams/plain_wrapper.c b/thirdparty/php/streams/plain_wrapper.c
index f4ad4ed9b..6751b6212 100644
--- a/thirdparty/php/streams/plain_wrapper.c
+++ b/thirdparty/php/streams/plain_wrapper.c
@@ -59,8 +59,13 @@ extern int php_get_gid_by_name(const char *name, gid_t *gid);
 # define PLAIN_WRAP_BUF_SIZE(st) (st)
 #endif
 
+#if PHP_VERSION_ID < 70400
 static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count);
 static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count);
+#else
+static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t count);
+static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count);
+#endif
 static int sw_php_stdiop_close(php_stream *stream, int close_handle);
 static int php_stdiop_stat(php_stream *stream, php_stream_statbuf *ssb);
 static int php_stdiop_flush(php_stream *stream);
@@ -216,7 +221,11 @@ static php_stream *_sw_php_stream_fopen_from_fd_int(int fd, const char *mode, co
     return php_stream_alloc_rel(&sw_php_stream_stdio_ops, self, persistent_id, mode);
 }
 
+#if PHP_VERSION_ID < 70400
 static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count)
+#else
+static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t count)
+#endif
 {
     php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
 
@@ -225,11 +234,15 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
     if (data->fd >= 0)
     {
         int bytes_written = write(data->fd, buf, count);
+#if PHP_VERSION_ID < 70400
         if (bytes_written < 0)
         {
             return 0;
         }
         return (size_t) bytes_written;
+#else
+        return bytes_written;
+#endif
     }
     else
     {
@@ -237,7 +250,11 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
     }
 }
 
+#if PHP_VERSION_ID < 70400
 static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
+#else
+static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
+#endif
 {
     php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
     size_t ret;
@@ -737,7 +754,11 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
 /* }}} */
 
 /* {{{ plain files opendir/readdir implementation */
+#if PHP_VERSION_ID < 70400
 static size_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count)
+#else
+static ssize_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count)
+#endif
 {
     DIR *dir = (DIR*) stream->abstract;
     struct dirent *result;