Skip to content

Commit

Permalink
Added convert_to_string.
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jul 17, 2015
1 parent 12c1200 commit f0d4653
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions swoole_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,11 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
{
int length;

if (SW_Z_TYPE_P(zdata) == IS_STRING)
{
length = Z_STRLEN_P(zdata);
*str = Z_STRVAL_P(zdata);
}
else if (SW_Z_TYPE_P(zdata) == IS_OBJECT)
if (SW_Z_TYPE_P(zdata) == IS_OBJECT)
{
if (!instanceof_function(Z_OBJCE_P(zdata), swoole_buffer_class_entry_ptr TSRMLS_CC))
{
swoole_php_fatal_error(E_WARNING, "object is not instanceof swoole_buffer.");
return SW_ERR;
goto convert;
}
swString *str_buffer = swoole_get_object(zdata);
if (!str_buffer->str)
Expand All @@ -124,8 +118,10 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
}
else
{
swoole_php_fatal_error(E_WARNING, "only supports string or swoole_buffer type.");
return SW_ERR;
convert:
convert_to_string(zdata);
length = Z_STRLEN_P(zdata);
*str = Z_STRVAL_P(zdata);
}

if (length >= SwooleG.serv->buffer_output_size)
Expand Down Expand Up @@ -2168,7 +2164,7 @@ PHP_FUNCTION(swoole_server_sendfile)
}
else
{
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &conn_fd, &filename, &send_data.info.len) == FAILURE)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &conn_fd, &filename, &len) == FAILURE)
{
return;
}
Expand Down

0 comments on commit f0d4653

Please sign in to comment.