Skip to content

Commit 087aa3a

Browse files
committed
first tests
1 parent 56aa6e5 commit 087aa3a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

ext/sockets/sockets.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,17 +2312,16 @@ PHP_FUNCTION(socket_set_option)
23122312
#ifdef SO_SPLICE
23132313
case SO_SPLICE: {
23142314
if (Z_TYPE_P(arg4) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(arg4), socket_so_splice_ce)) {
2315-
zend_argument_type_error(4, "must be of type object, %s given", zend_zval_value_name(arg4));
2315+
zend_argument_type_error(4, "must be of type SocketSoSplice, %s given", zend_zval_value_name(arg4));
23162316
RETURN_THROWS();
23172317
}
23182318

2319-
struct splice s = {0};
23202319
zend_object *so_splice_obj = Z_OBJ_P(arg4);
2321-
zval tmp;
2320+
zval tmpA, tmpB, tmpC;
23222321

2323-
zval *socket = zend_read_property(socket_so_splice_ce, so_splice_obj, "socket", strlen("socket"), 0, &tmp);
2324-
zval *max = zend_read_property(socket_so_splice_ce, so_splice_obj, "max", strlen("max"), 0, &tmp);
2325-
zval *array = zend_read_property(socket_so_splice_ce, so_splice_obj, "time", strlen("time"), 0, &tmp);
2322+
zval *socket = zend_read_property(socket_so_splice_ce, so_splice_obj, "socket", strlen("socket"), 0, &tmpA);
2323+
zval *max = zend_read_property(socket_so_splice_ce, so_splice_obj, "max", strlen("max"), 0, &tmpB);
2324+
zval *array = zend_read_property(socket_so_splice_ce, so_splice_obj, "time", strlen("time"), 0, &tmpC);
23262325

23272326
php_socket *php_sock = Z_SOCKET_P(socket);
23282327
zend_long php_max = Z_LVAL_P(max);
@@ -2331,22 +2330,25 @@ PHP_FUNCTION(socket_set_option)
23312330
ENSURE_SOCKET_VALID(php_sock);
23322331

23332332
if (php_max < 0) {
2334-
zend_argument_value_error(4, "\"max\" key must be greater than equal to 0");
2333+
zend_argument_value_error(4, "\"max\" key must be greater than or equal to 0");
23352334
RETURN_THROWS();
23362335
}
23372336

23382337
zval *tv_sec;
23392338
zval *tv_usec;
23402339

2341-
if ((tv_sec = zend_hash_str_find(php_arr, "tv_sec", strlen("tv_sec"))) == NULL) {
2342-
zend_argument_value_error(4, "time must have key \"tv_sec\"");
2340+
if ((tv_sec = zend_hash_str_find(php_arr, "sec", strlen("sec"))) == NULL) {
2341+
zend_argument_value_error(4, "time must have key \"sec\"");
23432342
RETURN_THROWS();
23442343
}
2345-
if ((tv_usec = zend_hash_str_find(php_arr, "tv_usec", strlen("tv_usec"))) == NULL) {
2346-
zend_argument_value_error(4, "time must have key \"tv_sec\"");
2344+
if ((tv_usec = zend_hash_str_find(php_arr, "usec", strlen("usec"))) == NULL) {
2345+
zend_argument_value_error(4, "time must have key \"usec\"");
23472346
RETURN_THROWS();
23482347
}
23492348

2349+
struct splice s;
2350+
s.sp_fd = (int)php_sock->bsd_socket;
2351+
s.sp_max = (off_t)php_max;
23502352
if (Z_LVAL_P(tv_sec) > 999999) {
23512353
s.sp_idle.tv_sec = Z_LVAL_P(tv_sec) + (Z_LVAL_P(tv_usec) / 1000000);
23522354
s.sp_idle.tv_usec = Z_LVAL_P(tv_usec) % 1000000;
@@ -2355,9 +2357,6 @@ PHP_FUNCTION(socket_set_option)
23552357
s.sp_idle.tv_usec = Z_LVAL_P(tv_usec);
23562358
}
23572359

2358-
s.sp_fd = (int)php_sock->bsd_socket;
2359-
s.sp_max = (off_t)php_max;
2360-
23612360
opt_ptr = &s;
23622361
optlen = sizeof(s);
23632362
break;

0 commit comments

Comments
 (0)