@@ -119,9 +119,9 @@ zend_module_entry sysvmsg_module_entry = {
119
119
ZEND_GET_MODULE (sysvmsg )
120
120
#endif
121
121
122
- static void sysvmsg_release (zend_rsrc_list_entry * rsrc TSRMLS_DC )
122
+ static void sysvmsg_release (zend_resource * rsrc TSRMLS_DC )
123
123
{
124
- sysvmsg_queue_t * mq = (sysvmsg_queue_t * ) rsrc -> ptr ;
124
+ sysvmsg_queue_t * mq = (sysvmsg_queue_t * ) rsrc -> ptr ;
125
125
efree (mq );
126
126
}
127
127
@@ -164,27 +164,27 @@ PHP_FUNCTION(msg_set_queue)
164
164
return ;
165
165
}
166
166
167
- ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , & queue , -1 , "sysvmsg queue" , le_sysvmsg );
167
+ ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , queue , -1 , "sysvmsg queue" , le_sysvmsg );
168
168
169
169
if (msgctl (mq -> id , IPC_STAT , & stat ) == 0 ) {
170
- zval * * item ;
170
+ zval * item ;
171
171
172
172
/* now pull out members of data and set them in the stat buffer */
173
- if (zend_hash_find ( Z_ARRVAL_P (data ), "msg_perm.uid" , sizeof ("msg_perm.uid" ), ( void * * ) & item ) == SUCCESS ) {
173
+ if (( item = zend_hash_str_find ( Z_ARRVAL_P (data ), "msg_perm.uid" , sizeof ("msg_perm.uid" ) - 1 )) != NULL ) {
174
174
convert_to_long_ex (item );
175
- stat .msg_perm .uid = Z_LVAL_PP (item );
175
+ stat .msg_perm .uid = Z_LVAL_P (item );
176
176
}
177
- if (zend_hash_find ( Z_ARRVAL_P (data ), "msg_perm.gid" , sizeof ("msg_perm.gid" ), ( void * * ) & item ) == SUCCESS ) {
177
+ if (( item = zend_hash_str_find ( Z_ARRVAL_P (data ), "msg_perm.gid" , sizeof ("msg_perm.gid" ) - 1 )) != NULL ) {
178
178
convert_to_long_ex (item );
179
- stat .msg_perm .gid = Z_LVAL_PP (item );
179
+ stat .msg_perm .gid = Z_LVAL_P (item );
180
180
}
181
- if (zend_hash_find ( Z_ARRVAL_P (data ), "msg_perm.mode" , sizeof ("msg_perm.mode" ), ( void * * ) & item ) == SUCCESS ) {
181
+ if (( item = zend_hash_str_find ( Z_ARRVAL_P (data ), "msg_perm.mode" , sizeof ("msg_perm.mode" ) - 1 )) != NULL ) {
182
182
convert_to_long_ex (item );
183
- stat .msg_perm .mode = Z_LVAL_PP (item );
183
+ stat .msg_perm .mode = Z_LVAL_P (item );
184
184
}
185
- if (zend_hash_find ( Z_ARRVAL_P (data ), "msg_qbytes" , sizeof ("msg_qbytes" ), ( void * * ) & item ) == SUCCESS ) {
185
+ if (( item = zend_hash_str_find ( Z_ARRVAL_P (data ), "msg_qbytes" , sizeof ("msg_qbytes" ) - 1 )) != NULL ) {
186
186
convert_to_long_ex (item );
187
- stat .msg_qbytes = Z_LVAL_PP (item );
187
+ stat .msg_qbytes = Z_LVAL_P (item );
188
188
}
189
189
if (msgctl (mq -> id , IPC_SET , & stat ) == 0 ) {
190
190
RETVAL_TRUE ;
@@ -207,7 +207,7 @@ PHP_FUNCTION(msg_stat_queue)
207
207
return ;
208
208
}
209
209
210
- ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , & queue , -1 , "sysvmsg queue" , le_sysvmsg );
210
+ ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , queue , -1 , "sysvmsg queue" , le_sysvmsg );
211
211
212
212
if (msgctl (mq -> id , IPC_STAT , & stat ) == 0 ) {
213
213
array_init (return_value );
@@ -226,7 +226,6 @@ PHP_FUNCTION(msg_stat_queue)
226
226
}
227
227
/* }}} */
228
228
229
-
230
229
/* {{{ proto bool msg_queue_exists(int key)
231
230
Check whether a message queue exists */
232
231
PHP_FUNCTION (msg_queue_exists )
@@ -245,7 +244,6 @@ PHP_FUNCTION(msg_queue_exists)
245
244
}
246
245
/* }}} */
247
246
248
-
249
247
/* {{{ proto resource msg_get_queue(int key [, int perms])
250
248
Attach to a message queue */
251
249
PHP_FUNCTION (msg_get_queue )
@@ -271,7 +269,7 @@ PHP_FUNCTION(msg_get_queue)
271
269
RETURN_FALSE ;
272
270
}
273
271
}
274
- RETVAL_RESOURCE (zend_list_insert (mq , le_sysvmsg TSRMLS_CC ));
272
+ RETVAL_ZVAL (zend_list_insert (mq , le_sysvmsg TSRMLS_CC ), 0 , 0 );
275
273
}
276
274
/* }}} */
277
275
@@ -286,7 +284,7 @@ PHP_FUNCTION(msg_remove_queue)
286
284
return ;
287
285
}
288
286
289
- ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , & queue , -1 , "sysvmsg queue" , le_sysvmsg );
287
+ ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , queue , -1 , "sysvmsg queue" , le_sysvmsg );
290
288
291
289
if (msgctl (mq -> id , IPC_RMID , NULL ) == 0 ) {
292
290
RETVAL_TRUE ;
@@ -338,18 +336,21 @@ PHP_FUNCTION(msg_receive)
338
336
}
339
337
}
340
338
341
- ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , & queue , -1 , "sysvmsg queue" , le_sysvmsg );
339
+ ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , queue , -1 , "sysvmsg queue" , le_sysvmsg );
342
340
343
341
messagebuffer = (struct php_msgbuf * ) safe_emalloc (maxsize , 1 , sizeof (struct php_msgbuf ));
344
342
345
343
result = msgrcv (mq -> id , messagebuffer , maxsize , desiredmsgtype , realflags );
346
344
345
+ ZVAL_DEREF (out_msgtype );
346
+ ZVAL_DEREF (out_message );
347
347
zval_dtor (out_msgtype );
348
348
zval_dtor (out_message );
349
349
ZVAL_LONG (out_msgtype , 0 );
350
350
ZVAL_FALSE (out_message );
351
351
352
352
if (zerrcode ) {
353
+ ZVAL_DEREF (zerrcode );
353
354
zval_dtor (zerrcode );
354
355
ZVAL_LONG (zerrcode , 0 );
355
356
}
@@ -361,21 +362,19 @@ PHP_FUNCTION(msg_receive)
361
362
RETVAL_TRUE ;
362
363
if (do_unserialize ) {
363
364
php_unserialize_data_t var_hash ;
364
- zval * tmp = NULL ;
365
+ zval tmp ;
365
366
const unsigned char * p = (const unsigned char * ) messagebuffer -> mtext ;
366
367
367
- MAKE_STD_ZVAL (tmp );
368
368
PHP_VAR_UNSERIALIZE_INIT (var_hash );
369
369
if (!php_var_unserialize (& tmp , & p , p + result , & var_hash TSRMLS_CC )) {
370
370
php_error_docref (NULL TSRMLS_CC , E_WARNING , "message corrupted ");
371
371
RETVAL_FALSE ;
372
372
} else {
373
- REPLACE_ZVAL_VALUE ( & out_message , tmp , 0 );
373
+ ZVAL_COPY_VALUE ( out_message , & tmp );
374
374
}
375
- FREE_ZVAL (tmp );
376
375
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
377
376
} else {
378
- ZVAL_STRINGL (out_message , messagebuffer -> mtext , result , 1 );
377
+ ZVAL_STRINGL (out_message , messagebuffer -> mtext , result );
379
378
}
380
379
} else if (zerrcode ) {
381
380
ZVAL_LONG (zerrcode , errno );
@@ -403,21 +402,21 @@ PHP_FUNCTION(msg_send)
403
402
return ;
404
403
}
405
404
406
- ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , & queue , -1 , "sysvmsg queue" , le_sysvmsg );
405
+ ZEND_FETCH_RESOURCE (mq , sysvmsg_queue_t * , queue , -1 , "sysvmsg queue" , le_sysvmsg );
407
406
408
407
if (do_serialize ) {
409
408
smart_str msg_var = {0 };
410
409
php_serialize_data_t var_hash ;
411
410
412
411
PHP_VAR_SERIALIZE_INIT (var_hash );
413
- php_var_serialize (& msg_var , & message , & var_hash TSRMLS_CC );
412
+ php_var_serialize (& msg_var , message , & var_hash TSRMLS_CC );
414
413
PHP_VAR_SERIALIZE_DESTROY (var_hash );
415
414
416
415
/* NB: php_msgbuf is 1 char bigger than a long, so there is no need to
417
416
* allocate the extra byte. */
418
- messagebuffer = safe_emalloc (msg_var .len , 1 , sizeof (struct php_msgbuf ));
419
- memcpy (messagebuffer -> mtext , msg_var .c , msg_var .len + 1 );
420
- message_len = msg_var .len ;
417
+ messagebuffer = safe_emalloc (msg_var .s -> len , 1 , sizeof (struct php_msgbuf ));
418
+ memcpy (messagebuffer -> mtext , msg_var .s -> val , msg_var .s -> len + 1 );
419
+ message_len = msg_var .s -> len ;
421
420
smart_str_free (& msg_var );
422
421
} else {
423
422
char * p ;
@@ -428,14 +427,17 @@ PHP_FUNCTION(msg_send)
428
427
break ;
429
428
430
429
case IS_LONG :
431
- case IS_BOOL :
432
430
message_len = spprintf (& p , 0 , "%ld" , Z_LVAL_P (message ));
433
431
break ;
434
-
432
+ case IS_FALSE :
433
+ message_len = spprintf (& p , 0 , "0" );
434
+ break ;
435
+ case IS_TRUE :
436
+ message_len = spprintf (& p , 0 , "1" );
437
+ break ;
435
438
case IS_DOUBLE :
436
439
message_len = spprintf (& p , 0 , "%F" , Z_DVAL_P (message ));
437
440
break ;
438
-
439
441
default :
440
442
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Message parameter must be either a string or a number." );
441
443
RETURN_FALSE ;
@@ -459,6 +461,7 @@ PHP_FUNCTION(msg_send)
459
461
if (result == -1 ) {
460
462
php_error_docref (NULL TSRMLS_CC , E_WARNING , "msgsnd failed: %s" , strerror (errno ));
461
463
if (zerror ) {
464
+ ZVAL_DEREF (zerror );
462
465
ZVAL_LONG (zerror , errno );
463
466
}
464
467
} else {
0 commit comments