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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
From 880d84cd838f334d88adb888f8a3b744194560d3 Mon Sep 17 00:00:00 2001
From: Bob Weinand <bobwei9@hotmail.com>
Date: Mon, 30 Oct 2017 14:37:56 +0100
Subject: [PATCH] PHP 7.3 compatibility
---
php_uv.c | 78 ++++++++++++++++++++++++++++++++++------------------------------
1 file changed, 41 insertions(+), 37 deletions(-)
diff --git a/php_uv.c b/php_uv.c
index df41fc9..564722c 100644
--- a/php_uv.c
+++ b/php_uv.c
@@ -44,6 +44,10 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_DECLARE_MODULE_GLOBALS(uv);
+#if PHP_VERSION_ID < 70300
+ #define GC_ADDREF(ref) ++GC_REFCOUNT(ref)
+#endif
+
#if PHP_VERSION_ID < 70100
#define uv_zend_wrong_parameter_class_error(throw, ...) zend_wrong_paramer_class_error(__VA_ARGS__)
#elif PHP_VERSION_ID < 70200
@@ -498,7 +502,7 @@ static php_uv_cb_t* php_uv_cb_init_dynamic(php_uv_t *uv, zend_fcall_info *fci, z
if (ZEND_FCI_INITIALIZED(*fci)) {
Z_TRY_ADDREF(cb->fci.function_name);
if (fci->object) {
- GC_REFCOUNT(cb->fci.object)++;
+ GC_ADDREF(cb->fci.object);
}
}
@@ -528,7 +532,7 @@ static void php_uv_cb_init(php_uv_cb_t **result, php_uv_t *uv, zend_fcall_info *
if (ZEND_FCI_INITIALIZED(*fci)) {
Z_TRY_ADDREF(cb->fci.function_name);
if (fci->object) {
- GC_REFCOUNT(cb->fci.object)++;
+ GC_ADDREF(cb->fci.object);
}
}
@@ -1250,7 +1254,7 @@ void static destruct_uv(zend_object *obj)
if (!php_uv_closeable_type(uv)) {
if (uv_cancel(&uv->uv.req) == UV_EBUSY) {
- ++GC_REFCOUNT(obj);
+ GC_ADDREF(obj);
}
clean_uv_handle(uv);
} else {
@@ -1546,7 +1550,7 @@ static void php_uv_listen_cb(uv_stream_t* server, int status)
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
ZVAL_OBJ(¶ms[0], &uv->std);
- ++GC_REFCOUNT(&uv->std);
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_listen_cb, uv);
ZVAL_LONG(¶ms[1], status);
@@ -1589,7 +1593,7 @@ static void php_uv_read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* b
ZVAL_OBJ(¶ms[0], &uv->std);
if (nread > 0) { // uv disables itself when it reaches EOF/error
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_read_cb, uv);
}
@@ -1626,7 +1630,7 @@ static void php_uv_read2_cb(uv_pipe_t* handle, ssize_t nread, uv_buf_t buf, uv_h
ZVAL_OBJ(¶ms[0], &uv->std);
if (nread > 0) { // uv disables itself when it reaches EOF/error
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_read2_cb, uv);
}
ZVAL_LONG(¶ms[1], nread);
@@ -1663,7 +1667,7 @@ static void php_uv_prepare_cb(uv_prepare_t* handle)
PHP_UV_DEBUG_PRINT("prepare_cb\n");
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_prepare_cb, uv);
php_uv_do_callback2(&retval, uv, params, 1, PHP_UV_PREPARE_CB TSRMLS_CC);
@@ -1684,7 +1688,7 @@ static void php_uv_check_cb(uv_check_t* handle)
PHP_UV_DEBUG_PRINT("check_cb\n");
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_check_cb, uv);
php_uv_do_callback2(&retval, uv, params, 1, PHP_UV_CHECK_CB TSRMLS_CC);
@@ -1706,7 +1710,7 @@ static void php_uv_async_cb(uv_async_t* handle)
PHP_UV_DEBUG_PRINT("async_cb\n");
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_async_cb, uv);
php_uv_do_callback2(&retval, uv, params, 1, PHP_UV_ASYNC_CB TSRMLS_CC);
@@ -1909,7 +1913,7 @@ static void php_uv_fs_event_cb(uv_fs_event_t* req, const char* filename, int eve
PHP_UV_DEBUG_PRINT("fs_event_cb: %s, %d\n", filename, status);
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_fs_event_cb, uv);
if (filename) {
ZVAL_STRING(¶ms[1], filename);
@@ -1964,7 +1968,7 @@ static void php_uv_fs_poll_cb(uv_fs_poll_t* handle, int status, const uv_stat_t*
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_fs_poll_cb, uv);
ZVAL_LONG(¶ms[1], status);
params[2] = php_uv_stat_to_zval(prev);
@@ -1990,7 +1994,7 @@ static void php_uv_poll_cb(uv_poll_t* handle, int status, int events)
ZVAL_OBJ(¶ms[0], &uv->std);
if (status == 0) {
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
}
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_poll_cb, uv);
ZVAL_LONG(¶ms[1], status);
@@ -2022,7 +2026,7 @@ static void php_uv_udp_recv_cb(uv_udp_t* handle, ssize_t nread, const uv_buf_t*
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_udp_recv_cb, uv);
ZVAL_LONG(¶ms[1], nread);
ZVAL_STRINGL(¶ms[2], buf->base, nread);
@@ -2081,7 +2085,7 @@ static void php_uv_close(php_uv_t *uv) {
ZEND_ASSERT(!uv_is_closing(&uv->uv.handle));
if (!php_uv_is_handle_referenced(uv)) {
- ++GC_REFCOUNT(&uv->std);
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(php_uv_close, uv);
}
@@ -2099,7 +2103,7 @@ static void php_uv_idle_cb(uv_timer_t *handle)
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(php_uv_idle_cb, uv);
php_uv_do_callback2(&retval, uv, params, 1, PHP_UV_IDLE_CB TSRMLS_CC);
@@ -2167,7 +2171,7 @@ static void php_uv_timer_cb(uv_timer_t *handle)
ZVAL_OBJ(¶ms[0], &uv->std);
if (handle->repeat) {
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(php_uv_timer_cb, uv);
}
@@ -2187,7 +2191,7 @@ static void php_uv_signal_cb(uv_signal_t *handle, int sig_num)
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
ZVAL_OBJ(¶ms[0], &uv->std);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(php_uv_signal_cb, uv);
ZVAL_LONG(¶ms[1], sig_num);
@@ -2347,7 +2351,7 @@ static void php_uv_udp_send(int type, INTERNAL_FUNCTION_PARAMETERS)
Z_PARAM_FUNC_EX(fci, fcc, 1, 0)
ZEND_PARSE_PARAMETERS_END();
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_udp_send, uv);
PHP_UV_INIT_SEND_REQ(w, uv, data->val, data->len);
@@ -2376,7 +2380,7 @@ static void php_uv_tcp_connect(enum php_uv_socket_type type, INTERNAL_FUNCTION_P
Z_PARAM_FUNC_EX(fci, fcc, 1, 0)
ZEND_PARSE_PARAMETERS_END();
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_tcp_connect, uv);
PHP_UV_INIT_CONNECT(req, uv)
@@ -3499,7 +3503,7 @@ PHP_FUNCTION(uv_signal_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_signal_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_SIGNAL_CB);
@@ -3613,7 +3617,7 @@ PHP_FUNCTION(uv_write)
php_uv_free_write_req(w);
php_error_docref(NULL, E_WARNING, "write failed");
} else {
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_write, uv);
}
}
@@ -3646,7 +3650,7 @@ PHP_FUNCTION(uv_write2)
php_uv_free_write_req(w);
php_error_docref(NULL, E_ERROR, "write2 failed");
} else {
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_write2, uv);
}
}
@@ -3714,7 +3718,7 @@ PHP_FUNCTION(uv_shutdown)
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_SHUTDOWN_CB);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_shutdown, uv);
shutdown = emalloc(sizeof(uv_shutdown_t));
shutdown->data = uv;
@@ -3777,7 +3781,7 @@ PHP_FUNCTION(uv_read_start)
return;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_read_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_READ_CB);
@@ -3810,7 +3814,7 @@ PHP_FUNCTION(uv_read2_start)
Z_PARAM_FUNC(fci, fcc)
ZEND_PARSE_PARAMETERS_END();
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_read2_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_READ2_CB);
@@ -3902,7 +3906,7 @@ PHP_FUNCTION(uv_listen)
Z_PARAM_FUNC(fci, fcc)
ZEND_PARSE_PARAMETERS_END();
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_listen, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_LISTEN_CB);
@@ -3986,7 +3990,7 @@ PHP_FUNCTION(uv_timer_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_timer_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_TIMER_CB);
@@ -4035,7 +4039,7 @@ PHP_FUNCTION(uv_timer_again)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_timer_again, uv);
uv_timer_again(&uv->uv.timer);
@@ -4114,7 +4118,7 @@ PHP_FUNCTION(uv_idle_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_idle_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_IDLE_CB);
@@ -4232,7 +4236,7 @@ PHP_FUNCTION(uv_tcp_open)
PHP_FUNCTION(uv_default_loop)
{
php_uv_loop_t *loop = php_uv_default_loop();
- ++GC_REFCOUNT(&loop->std);
+ GC_ADDREF(&loop->std);
RETURN_OBJ(&loop->std);
}
/* }}} */
@@ -4309,7 +4313,7 @@ PHP_FUNCTION(uv_udp_recv_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_udp_recv_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_RECV_CB);
@@ -4631,7 +4635,7 @@ PHP_FUNCTION(uv_pipe_connect)
Z_PARAM_FUNC(fci, fcc)
ZEND_PARSE_PARAMETERS_END();
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_pipe_connect, uv);
req = (uv_connect_t *) emalloc(sizeof(uv_connect_t));
@@ -5093,7 +5097,7 @@ PHP_FUNCTION(uv_spawn)
RETVAL_LONG(ret);
} else {
php_uv_cb_init(&cb, proc, &fci, &fcc, PHP_UV_PROC_CLOSE_CB);
- ++GC_REFCOUNT(&proc->std);
+ GC_ADDREF(&proc->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_spawn, proc);
RETVAL_OBJ(&proc->std);
}
@@ -5344,7 +5348,7 @@ PHP_FUNCTION(uv_prepare_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_prepare_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_PREPARE_CB);
@@ -5421,7 +5425,7 @@ PHP_FUNCTION(uv_check_start)
RETURN_FALSE;
}
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_check_start, uv);
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_CHECK_CB);
@@ -5993,7 +5997,7 @@ PHP_FUNCTION(uv_poll_start)
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_POLL_CB);
if (!uv_is_active(&uv->uv.handle)) {
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_poll_start, uv);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
}
error = uv_poll_start(&uv->uv.poll, events, php_uv_poll_cb);
@@ -6064,7 +6068,7 @@ PHP_FUNCTION(uv_fs_poll_start)
ZEND_PARSE_PARAMETERS_END();
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_FS_POLL_CB);
- GC_REFCOUNT(&uv->std)++;
+ GC_ADDREF(&uv->std);
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(uv_fs_poll_start, uv);
error = uv_fs_poll_start(&uv->uv.fs_poll, php_uv_fs_poll_cb, (const char*)path->val, interval);
|