From b06dac0603f2e08093f7ccd3f6fc84aea79c814e Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Wed, 20 Aug 2014 18:43:06 +0800 Subject: [PATCH 01/15] Removed 'bundled' submodule and updated Travis --- .gitmodules | 4 ---- .travis.yml | 2 +- libuv | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 160000 libuv diff --git a/.gitmodules b/.gitmodules index 35f9a76..050c654 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "libuv"] - path = libuv - url = https://github.com/joyent/libuv.git - ignore = dirty [submodule "http-parser"] path = http-parser url = https://github.com/joyent/http-parser.git diff --git a/.travis.yml b/.travis.yml index 3118cbb..52d5b75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ php: - 5.5 before_script: - - cd libuv && make libuv.a CFLAGS=-fPIC -s && cd .. + - sudo apt-get install libuv-devel - phpize && ./configure && make && sudo make install - echo "extension=uv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` diff --git a/libuv b/libuv deleted file mode 160000 index 375ebce..0000000 --- a/libuv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 375ebce068555f0ca8151b562edb5f1b263022db From 77240aa6826237315f4f100e83286e473a86676a Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Tue, 19 Aug 2014 23:47:35 +0800 Subject: [PATCH 02/15] Using --with-uv[=DIR] configure line --- config.m4 | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/config.m4 b/config.m4 index c1d0916..4f816d8 100644 --- a/config.m4 +++ b/config.m4 @@ -1,5 +1,5 @@ -PHP_ARG_ENABLE(uv, Whether to enable the "uv" extension, -[ --enable-uv Enable "uv" extension support]) +PHP_ARG_WITH(uv, Whether to include "uv" support, +[ --with-uv[=DIR] Include "uv" support]) PHP_ARG_ENABLE(httpparser, Whether to enable the "httpparser" module, [ --enable-httpparser Enable "httpparser" module support]) @@ -53,23 +53,43 @@ if test $PHP_UV != "no"; then if test $PHP_HTTPPARSER != "no"; then PHP_ADD_INCLUDE([$ext_srcdir/http-parser]) fi - PHP_ADD_INCLUDE([$ext_srcdir/libuv/include]) - CFLAGS=" $CFLAGS -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement -Wl,libuv/libuv.a" + SEARCH_PATH="/usr/local /usr" + SEARCH_FOR="/include/uv.h" + if test -r $PHP_UV/$SEARCH_FOR; then # path given as parameter + UV_DIR=$PHP_UV + else # search default path list + AC_MSG_CHECKING([for libuv files in default path]) + for i in $SEARCH_PATH ; do + if test -r $i/$SEARCH_FOR; then + UV_DIR=$i + AC_MSG_RESULT(found in $i) + fi + done + fi - case $host in - *darwin*) - dnl these macro does not work. why? - dnl - dnl PHP_ADD_FRAMEWORK(CoreServices) - dnl PHP_ADD_FRAMEWORK(Carbon) + PHP_ADD_INCLUDE($UV_DIR/include) - CFLAGS="$CFLAGS -framework CoreServices -framework Carbon" - ;; - *linux*) - CFLAGS="$CFLAGS -lrt" - esac + PHP_CHECK_LIBRARY(uv, uv_version, + [ + PHP_ADD_LIBRARY_WITH_PATH(uv, $UV_DIR/lib, UV_SHARED_LIBADD) + AC_DEFINE(HAVE_UVLIB,1,[ ]) + ],[ + AC_MSG_ERROR([wrong uv library version or library not found]) + ],[ + -L$UV_DIR/lib -lm + ]) PHP_SUBST(UV_SHARED_LIBADD) - PHP_SUBST([CFLAGS]) + +# CFLAGS=" $CFLAGS -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement" + +# case $host in +# *darwin*) +# ;; +# *linux*) +# CFLAGS="$CFLAGS -lrt" +# esac + +# PHP_SUBST([CFLAGS]) fi From 90f12cb77fb93f685bf8662ea05857b8e4582fe3 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Tue, 19 Aug 2014 23:56:11 +0800 Subject: [PATCH 03/15] Moving parser functionality in a separate file (part 1) --- php_uv.c | 272 +--------------------------------------------- php_uv.h | 17 --- uv.c | 4 - uv_http_parser.c | 277 +++++++++++++++++++++++++++++++++++++++++++++++ uv_http_parser.h | 17 +++ 5 files changed, 297 insertions(+), 290 deletions(-) create mode 100644 uv_http_parser.c create mode 100644 uv_http_parser.h diff --git a/php_uv.c b/php_uv.c index 99e4b8b..dde74df 100644 --- a/php_uv.c +++ b/php_uv.c @@ -230,8 +230,6 @@ static int uv_sockaddr_handle; static int uv_lock_handle; -static int uv_httpparser_handle; - static int uv_stdio_handle; @@ -2322,20 +2320,6 @@ static inline uv_stream_t* php_uv_get_current_stream(php_uv_t *uv) return stream; } -void static destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - php_http_parser_context *obj = (php_http_parser_context *)rsrc->ptr; - - if (obj->headers) { - zval_ptr_dtor(&obj->headers); - } - if (obj->data) { - zval_ptr_dtor(&obj->data); - } - - efree(obj); -} - void static destruct_uv_stdio(zend_rsrc_list_entry *rsrc TSRMLS_DC) { php_uv_stdio_t *obj = (php_uv_stdio_t *)rsrc->ptr; @@ -2348,134 +2332,6 @@ void static destruct_uv_stdio(zend_rsrc_list_entry *rsrc TSRMLS_DC) efree(obj); } -/* http parser callbacks */ -static int on_message_begin(http_parser *p) -{ - return 0; -} - -static int on_headers_complete(http_parser *p) -{ - return 0; -} - -static int on_message_complete(http_parser *p) -{ - php_http_parser_context *result = p->data; - result->finished = 1; - - if (result->tmp != NULL) { - efree(result->tmp); - result->tmp = NULL; - result->tmp_len = 0; - } - - return 0; -} - -#define PHP_HTTP_PARSER_PARSE_URL(flag, name) \ - if (result->handle.field_set & (1 << flag)) { \ - const char *tmp_name = at+result->handle.field_data[flag].off; \ - int length = result->handle.field_data[flag].len; \ - add_assoc_stringl(data, #name, (char*)tmp_name, length, 1); \ - } - -static int on_url_cb(http_parser *p, const char *at, size_t len) -{ - php_http_parser_context *result = p->data; - zval *data = result->data; - - http_parser_parse_url(at, len, 0, &result->handle); - add_assoc_stringl(data, "QUERY_STRING", (char*)at, len, 1); - - PHP_HTTP_PARSER_PARSE_URL(UF_SCHEMA, SCHEME); - PHP_HTTP_PARSER_PARSE_URL(UF_HOST, HOST); - PHP_HTTP_PARSER_PARSE_URL(UF_PORT, PORT); - PHP_HTTP_PARSER_PARSE_URL(UF_PATH, PATH); - PHP_HTTP_PARSER_PARSE_URL(UF_QUERY, QUERY); - PHP_HTTP_PARSER_PARSE_URL(UF_FRAGMENT, FRAGMENT); - - return 0; -} - -static int on_status_cb(http_parser *p, const char *at, size_t len) -{ - return 0; -} - -char *php_uv_strtoupper(char *s, size_t len) -{ - unsigned char *c, *e; - - c = (unsigned char *)s; - e = (unsigned char *)c+len; - - while (c < e) { - *c = toupper(*c); - if (*c == '-') *c = '_'; - c++; - } - return s; -} - - -static int header_field_cb(http_parser *p, const char *at, size_t len) -{ - php_http_parser_context *result = p->data; - - if (result->was_header_value) { - if (result->tmp != NULL) { - efree(result->tmp); - result->tmp = NULL; - result->tmp_len = 0; - } - result->tmp = estrndup(at, len); - php_uv_strtoupper(result->tmp, len); - result->tmp_len = len; - } else { - result->tmp = erealloc(result->tmp, len + result->tmp_len + 1); - memcpy(result->tmp + result->tmp_len, at, len); - result->tmp[result->tmp_len + len] = '\0'; - result->tmp_len = result->tmp_len + len; - } - - result->was_header_value = 0; - return 0; -} - -static int header_value_cb(http_parser *p, const char *at, size_t len) -{ - php_http_parser_context *result = p->data; - zval *data = result->headers; - - if (result->was_header_value) { - zval **element; - - if (zend_hash_find(Z_ARRVAL_P(data), result->tmp, result->tmp_len+1, (void **)&element) == SUCCESS) { - Z_STRVAL_PP(element) = erealloc(Z_STRVAL_PP(element), Z_STRLEN_PP(element) + len + 1); - memcpy(Z_STRVAL_PP(element) + Z_STRLEN_PP(element), at, len); - - Z_STRVAL_PP(element)[Z_STRLEN_PP(element)+len] = '\0'; - Z_STRLEN_PP(element) = Z_STRLEN_PP(element) + len; - } - } else { - add_assoc_stringl(data, result->tmp, (char*)at, len, 1); - } - - result->was_header_value = 1; - return 0; -} - -static int on_body_cb(http_parser *p, const char *at, size_t len) -{ - php_http_parser_context *result = p->data; - zval *data = result->headers; - - add_assoc_stringl(data, "BODY", (char*)at, len, 1); - - return 0; -} -/* end of callback */ /* common functions */ @@ -2717,7 +2573,7 @@ PHP_MINIT_FUNCTION(uv) uv_loop_handle = zend_register_list_destructors_ex(destruct_uv_loop, NULL, PHP_UV_LOOP_RESOURCE_NAME, module_number); uv_sockaddr_handle = zend_register_list_destructors_ex(destruct_uv_sockaddr, NULL, PHP_UV_SOCKADDR_RESOURCE_NAME, module_number); uv_lock_handle = zend_register_list_destructors_ex(destruct_uv_lock, NULL, PHP_UV_LOCK_RESOURCE_NAME, module_number); - uv_httpparser_handle = zend_register_list_destructors_ex(destruct_httpparser, NULL, PHP_UV_HTTPPARSER_RESOURCE_NAME, module_number); +// uv_httpparser_handle = zend_register_list_destructors_ex(destruct_httpparser, NULL, PHP_UV_HTTPPARSER_RESOURCE_NAME, module_number); uv_stdio_handle = zend_register_list_destructors_ex(destruct_uv_stdio, NULL, PHP_UV_STDIO_RESOURCE_NAME, module_number); return SUCCESS; @@ -6475,125 +6331,6 @@ PHP_FUNCTION(uv_fs_poll_stop) /* }}} */ -/* HTTP PARSER */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_init, 0, 0, 1) - ZEND_ARG_INFO(0, target) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_execute, 0, 0, 3) - ZEND_ARG_INFO(0, resource) - ZEND_ARG_INFO(0, buffer) - ZEND_ARG_INFO(0, setting) -ZEND_END_ARG_INFO() - -/* {{{ proto resource uv_http_parser_init(long $target = UV::HTTP_REQUEST) -*/ -PHP_FUNCTION(uv_http_parser_init) -{ - long target = HTTP_REQUEST; - zval *header, *result; - php_http_parser_context *ctx = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "|l",&target) == FAILURE) { - return; - } - - ctx = emalloc(sizeof(php_http_parser_context)); - http_parser_init(&ctx->parser, target); - - MAKE_STD_ZVAL(header); - array_init(header); - - MAKE_STD_ZVAL(result); - array_init(result); - - ctx->data = result; - ctx->headers = header; - ctx->finished = 0; - ctx->was_header_value = 1; - ctx->tmp = NULL; - ctx->tmp_len = 0; - - if (target == HTTP_RESPONSE) { - ctx->is_response = 1; - } else { - ctx->is_response = 0; - } - - memset(&ctx->handle, 0, sizeof(struct http_parser_url)); - - /* setup callback */ - ctx->settings.on_message_begin = on_message_begin; - ctx->settings.on_header_field = header_field_cb; - ctx->settings.on_header_value = header_value_cb; - ctx->settings.on_url = on_url_cb; - ctx->settings.on_status = on_status_cb; - ctx->settings.on_body = on_body_cb; - ctx->settings.on_headers_complete = on_headers_complete; - ctx->settings.on_message_complete = on_message_complete; - - ZEND_REGISTER_RESOURCE(return_value, ctx, uv_httpparser_handle); -} - -/* {{{ proto bool uv_http_parser_execute(resource $parser, string $body, array &$result) -*/ -PHP_FUNCTION(uv_http_parser_execute) -{ - zval *z_parser = NULL, *result = NULL, *version = NULL, *headers = NULL; - php_http_parser_context *context; - char *body; - int body_len; - char version_buffer[4] = {0}; - size_t nparsed = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "rs/a",&z_parser, &body, &body_len, &result) == FAILURE) { - return; - } - - ZEND_FETCH_RESOURCE(context, php_http_parser_context*, &z_parser, -1, PHP_UV_HTTPPARSER_RESOURCE_NAME, uv_httpparser_handle); - - if (context->finished == 1) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "passed uv_parser resource has already finished."); - RETURN_FALSE; - } - - context->parser.data = context; - nparsed = http_parser_execute(&context->parser, &context->settings, body, body_len); - - if (result) { - zval_dtor(result); - } - - if (nparsed != body_len) { - zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "parse failed"); - return; - } - - ZVAL_ZVAL(result, context->data, 1, 0); - if (context->is_response == 0) { - add_assoc_string(result, "REQUEST_METHOD", (char*)http_method_str(context->parser.method), 1); - } else { - add_assoc_long(result, "STATUS_CODE", (long)context->parser.status_code); - } - add_assoc_long(result, "UPGRADE", (long)context->parser.upgrade); - - MAKE_STD_ZVAL(version); - snprintf(version_buffer, 4, "%d.%d", context->parser.http_major, context->parser.http_minor); - ZVAL_STRING(version, version_buffer, 1); - - MAKE_STD_ZVAL(headers); - ZVAL_ZVAL(headers, context->headers, 1, 0); - add_assoc_zval(headers, "VERSION", version); - add_assoc_zval(result, "HEADERS", headers); - - if (context->finished == 1) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} static zend_function_entry uv_functions[] = { @@ -6770,9 +6507,6 @@ static zend_function_entry uv_functions[] = { PHP_FE(uv_signal_init, arginfo_uv_signal_init) PHP_FE(uv_signal_start, arginfo_uv_signal_start) PHP_FE(uv_signal_stop, arginfo_uv_signal_stop) - /* http parser */ - PHP_FE(uv_http_parser_init, arginfo_uv_http_parser_init) - PHP_FE(uv_http_parser_execute, arginfo_uv_http_parser_execute) {NULL, NULL, NULL} }; @@ -6783,14 +6517,14 @@ PHP_MINFO_FUNCTION(uv) char http_parser_version[20]; sprintf(uv_version, "%d.%d",UV_VERSION_MAJOR, UV_VERSION_MINOR); - sprintf(http_parser_version, "%d.%d",HTTP_PARSER_VERSION_MAJOR, HTTP_PARSER_VERSION_MINOR); +// sprintf(http_parser_version, "%d.%d",HTTP_PARSER_VERSION_MAJOR, HTTP_PARSER_VERSION_MINOR); php_printf("PHP libuv Extension\n"); php_info_print_table_start(); php_info_print_table_header(2,"libuv Support", "enabled"); php_info_print_table_row(2,"Version", PHP_UV_EXTVER); php_info_print_table_row(2,"libuv Version", uv_version); - php_info_print_table_row(2,"http-parser Version", http_parser_version); +// php_info_print_table_row(2,"http-parser Version", http_parser_version); php_info_print_table_end(); } diff --git a/php_uv.h b/php_uv.h index ce5b5a8..686c863 100755 --- a/php_uv.h +++ b/php_uv.h @@ -31,7 +31,6 @@ #include "php.h" #include "uv.h" -#include "http_parser.h" #include "php_network.h" #include "php_streams.h" @@ -189,22 +188,6 @@ typedef struct { int flags; } php_uv_stdio_t; - -typedef struct { - struct http_parser parser; - struct http_parser_url handle; - struct http_parser_settings settings; - int is_response; - int was_header_value; - int finished; - zval *data; - zval *headers; - char *tmp; - size_t tmp_len; -} php_http_parser_context; - -#define PHP_UV_HTTPPARSER_RESOURCE_NAME "uv_httpparser" - #define PHP_UV_RESOURCE_NAME "uv" #define PHP_UV_SOCKADDR_RESOURCE_NAME "uv_sockaddr" #define PHP_UV_LOOP_RESOURCE_NAME "uv_loop" diff --git a/uv.c b/uv.c index 9281f71..6094379 100755 --- a/uv.c +++ b/uv.c @@ -139,10 +139,6 @@ static int php_uv_class_init(TSRMLS_D) zend_declare_class_constant_long(uv_class_entry, "LEAVE_GROUP", sizeof("LEAVE_GROUP")-1, UV_LEAVE_GROUP TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "JOIN_GROUP", sizeof("JOIN_GROUP")-1, UV_JOIN_GROUP TSRMLS_CC); - zend_declare_class_constant_long(uv_class_entry, "HTTP_BOTH", sizeof("HTTP_BOTH")-1, HTTP_BOTH TSRMLS_CC); - zend_declare_class_constant_long(uv_class_entry, "HTTP_REQUEST", sizeof("HTTP_REQUEST")-1, HTTP_REQUEST TSRMLS_CC); - zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); - /* for uv_handle_type */ zend_declare_class_constant_long(uv_class_entry, "IS_UV_TCP", sizeof("IS_UV_TCP")-1, IS_UV_TCP TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "IS_UV_UDP", sizeof("IS_UV_UDP")-1, IS_UV_UDP TSRMLS_CC); diff --git a/uv_http_parser.c b/uv_http_parser.c new file mode 100644 index 0000000..3c4ea28 --- /dev/null +++ b/uv_http_parser.c @@ -0,0 +1,277 @@ +static int uv_httpparser_handle; + +void static destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) +{ + php_http_parser_context *obj = (php_http_parser_context *)rsrc->ptr; + + if (obj->headers) { + zval_ptr_dtor(&obj->headers); + } + if (obj->data) { + zval_ptr_dtor(&obj->data); + } + + efree(obj); +} + +/* http parser callbacks */ +static int on_message_begin(http_parser *p) +{ + return 0; +} + +static int on_headers_complete(http_parser *p) +{ + return 0; +} + +static int on_message_complete(http_parser *p) +{ + php_http_parser_context *result = p->data; + result->finished = 1; + + if (result->tmp != NULL) { + efree(result->tmp); + result->tmp = NULL; + result->tmp_len = 0; + } + + return 0; +} + +#define PHP_HTTP_PARSER_PARSE_URL(flag, name) \ + if (result->handle.field_set & (1 << flag)) { \ + const char *tmp_name = at+result->handle.field_data[flag].off; \ + int length = result->handle.field_data[flag].len; \ + add_assoc_stringl(data, #name, (char*)tmp_name, length, 1); \ + } + +static int on_url_cb(http_parser *p, const char *at, size_t len) +{ + php_http_parser_context *result = p->data; + zval *data = result->data; + + http_parser_parse_url(at, len, 0, &result->handle); + add_assoc_stringl(data, "QUERY_STRING", (char*)at, len, 1); + + PHP_HTTP_PARSER_PARSE_URL(UF_SCHEMA, SCHEME); + PHP_HTTP_PARSER_PARSE_URL(UF_HOST, HOST); + PHP_HTTP_PARSER_PARSE_URL(UF_PORT, PORT); + PHP_HTTP_PARSER_PARSE_URL(UF_PATH, PATH); + PHP_HTTP_PARSER_PARSE_URL(UF_QUERY, QUERY); + PHP_HTTP_PARSER_PARSE_URL(UF_FRAGMENT, FRAGMENT); + + return 0; +} + +static int on_status_cb(http_parser *p, const char *at, size_t len) +{ + return 0; +} + +char *php_uv_strtoupper(char *s, size_t len) +{ + unsigned char *c, *e; + + c = (unsigned char *)s; + e = (unsigned char *)c+len; + + while (c < e) { + *c = toupper(*c); + if (*c == '-') *c = '_'; + c++; + } + return s; +} + + +static int header_field_cb(http_parser *p, const char *at, size_t len) +{ + php_http_parser_context *result = p->data; + + if (result->was_header_value) { + if (result->tmp != NULL) { + efree(result->tmp); + result->tmp = NULL; + result->tmp_len = 0; + } + result->tmp = estrndup(at, len); + php_uv_strtoupper(result->tmp, len); + result->tmp_len = len; + } else { + result->tmp = erealloc(result->tmp, len + result->tmp_len + 1); + memcpy(result->tmp + result->tmp_len, at, len); + result->tmp[result->tmp_len + len] = '\0'; + result->tmp_len = result->tmp_len + len; + } + + result->was_header_value = 0; + return 0; +} + +static int header_value_cb(http_parser *p, const char *at, size_t len) +{ + php_http_parser_context *result = p->data; + zval *data = result->headers; + + if (result->was_header_value) { + zval **element; + + if (zend_hash_find(Z_ARRVAL_P(data), result->tmp, result->tmp_len+1, (void **)&element) == SUCCESS) { + Z_STRVAL_PP(element) = erealloc(Z_STRVAL_PP(element), Z_STRLEN_PP(element) + len + 1); + memcpy(Z_STRVAL_PP(element) + Z_STRLEN_PP(element), at, len); + + Z_STRVAL_PP(element)[Z_STRLEN_PP(element)+len] = '\0'; + Z_STRLEN_PP(element) = Z_STRLEN_PP(element) + len; + } + } else { + add_assoc_stringl(data, result->tmp, (char*)at, len, 1); + } + + result->was_header_value = 1; + return 0; +} + +static int on_body_cb(http_parser *p, const char *at, size_t len) +{ + php_http_parser_context *result = p->data; + zval *data = result->headers; + + add_assoc_stringl(data, "BODY", (char*)at, len, 1); + + return 0; +} +/* end of callback */ + +/* HTTP PARSER */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_init, 0, 0, 1) + ZEND_ARG_INFO(0, target) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_execute, 0, 0, 3) + ZEND_ARG_INFO(0, resource) + ZEND_ARG_INFO(0, buffer) + ZEND_ARG_INFO(0, setting) +ZEND_END_ARG_INFO() + +/* {{{ proto resource uv_http_parser_init(long $target = UV::HTTP_REQUEST) +*/ +PHP_FUNCTION(uv_http_parser_init) +{ + long target = HTTP_REQUEST; + zval *header, *result; + php_http_parser_context *ctx = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "|l",&target) == FAILURE) { + return; + } + + ctx = emalloc(sizeof(php_http_parser_context)); + http_parser_init(&ctx->parser, target); + + MAKE_STD_ZVAL(header); + array_init(header); + + MAKE_STD_ZVAL(result); + array_init(result); + + ctx->data = result; + ctx->headers = header; + ctx->finished = 0; + ctx->was_header_value = 1; + ctx->tmp = NULL; + ctx->tmp_len = 0; + + if (target == HTTP_RESPONSE) { + ctx->is_response = 1; + } else { + ctx->is_response = 0; + } + + memset(&ctx->handle, 0, sizeof(struct http_parser_url)); + + /* setup callback */ + ctx->settings.on_message_begin = on_message_begin; + ctx->settings.on_header_field = header_field_cb; + ctx->settings.on_header_value = header_value_cb; + ctx->settings.on_url = on_url_cb; + ctx->settings.on_status = on_status_cb; + ctx->settings.on_body = on_body_cb; + ctx->settings.on_headers_complete = on_headers_complete; + ctx->settings.on_message_complete = on_message_complete; + + ZEND_REGISTER_RESOURCE(return_value, ctx, uv_httpparser_handle); +} + +/* {{{ proto bool uv_http_parser_execute(resource $parser, string $body, array &$result) +*/ +PHP_FUNCTION(uv_http_parser_execute) +{ + zval *z_parser = NULL, *result = NULL, *version = NULL, *headers = NULL; + php_http_parser_context *context; + char *body; + int body_len; + char version_buffer[4] = {0}; + size_t nparsed = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "rs/a",&z_parser, &body, &body_len, &result) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(context, php_http_parser_context*, &z_parser, -1, PHP_UV_HTTPPARSER_RESOURCE_NAME, uv_httpparser_handle); + + if (context->finished == 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "passed uv_parser resource has already finished."); + RETURN_FALSE; + } + + context->parser.data = context; + nparsed = http_parser_execute(&context->parser, &context->settings, body, body_len); + + if (result) { + zval_dtor(result); + } + + if (nparsed != body_len) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "parse failed"); + return; + } + + ZVAL_ZVAL(result, context->data, 1, 0); + if (context->is_response == 0) { + add_assoc_string(result, "REQUEST_METHOD", (char*)http_method_str(context->parser.method), 1); + } else { + add_assoc_long(result, "STATUS_CODE", (long)context->parser.status_code); + } + add_assoc_long(result, "UPGRADE", (long)context->parser.upgrade); + + MAKE_STD_ZVAL(version); + snprintf(version_buffer, 4, "%d.%d", context->parser.http_major, context->parser.http_minor); + ZVAL_STRING(version, version_buffer, 1); + + MAKE_STD_ZVAL(headers); + ZVAL_ZVAL(headers, context->headers, 1, 0); + add_assoc_zval(headers, "VERSION", version); + add_assoc_zval(result, "HEADERS", headers); + + if (context->finished == 1) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} + +// static zend_function_entry uv_functions[] = { + + /* http parser */ + PHP_FE(uv_http_parser_init, arginfo_uv_http_parser_init) + PHP_FE(uv_http_parser_execute, arginfo_uv_http_parser_execute) + +// php_uv_class_init + + zend_declare_class_constant_long(uv_class_entry, "HTTP_BOTH", sizeof("HTTP_BOTH")-1, HTTP_BOTH TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "HTTP_REQUEST", sizeof("HTTP_REQUEST")-1, HTTP_REQUEST TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); + diff --git a/uv_http_parser.h b/uv_http_parser.h new file mode 100644 index 0000000..a4d7a55 --- /dev/null +++ b/uv_http_parser.h @@ -0,0 +1,17 @@ +#include "http_parser.h" + +typedef struct { + struct http_parser parser; + struct http_parser_url handle; + struct http_parser_settings settings; + int is_response; + int was_header_value; + int finished; + zval *data; + zval *headers; + char *tmp; + size_t tmp_len; +} php_http_parser_context; + +#define PHP_UV_HTTPPARSER_RESOURCE_NAME "uv_httpparser" + From 3beb67167f0bb811e3231124a1d11e0cfa19d8c1 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Wed, 20 Aug 2014 18:46:09 +0800 Subject: [PATCH 04/15] Updated Travis configuration to work with --with-uv[=DIR] --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52d5b75..762b037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ language: php php: - - 5.3 - - 5.4 - - 5.5 + - 5.6 before_script: - - sudo apt-get install libuv-devel - - phpize && ./configure && make && sudo make install + - sudo apt-add-repository -y ppa:linuxjedi/ppa + - sudo apt-get update + - sudo apt-get -y install libuv-dev + - phpize && ./configure --with-uv && make && sudo make install - echo "extension=uv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` notifications: From be7ff58ae1ab97a56eb972ee53276ae0e2dc8009 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Wed, 20 Aug 2014 20:56:18 +0800 Subject: [PATCH 05/15] Fixed a few test cases --- tests/010-uv_ip4_addr.phpt | 4 ++-- tests/010-uv_ip6_addr.phpt | 4 ++-- tests/999-uv_http_parser.phpt | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/010-uv_ip4_addr.phpt b/tests/010-uv_ip4_addr.phpt index 8f128d9..de6fc4d 100644 --- a/tests/010-uv_ip4_addr.phpt +++ b/tests/010-uv_ip4_addr.phpt @@ -3,5 +3,5 @@ Check for uv_ip4_addr --FILE-- --FILE-- string(6) "sample" } -} \ No newline at end of file +} From b035466c66fd99fda75bfff065bb8bb8be614968 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Wed, 20 Aug 2014 20:57:03 +0800 Subject: [PATCH 06/15] Disable http parser by default for now --- config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.m4 b/config.m4 index 4f816d8..56c145f 100644 --- a/config.m4 +++ b/config.m4 @@ -2,10 +2,10 @@ PHP_ARG_WITH(uv, Whether to include "uv" support, [ --with-uv[=DIR] Include "uv" support]) PHP_ARG_ENABLE(httpparser, Whether to enable the "httpparser" module, - [ --enable-httpparser Enable "httpparser" module support]) + [ --enable-httpparser Enable "httpparser" module support], no, no) PHP_ARG_ENABLE(uv-debug, for uv debug support, - [ --enable-uv-debug Enable enable uv deubg support], no, no) + [ --enable-uv-debug Enable enable uv debug support], no, no) PHP_ARG_ENABLE(dtrace, Whether to enable the "dtrace" debug, [ --enable-dtrace Enable "dtrace" support], no, no) From 91ee8f491a87f156b19e11ed14b7304818cba3ea Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Wed, 20 Aug 2014 21:44:14 +0800 Subject: [PATCH 07/15] Fixed off-by-one overflow, updated test case --- php_uv.c | 14 ++++++++------ tests/999-uv_chdir.phpt | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/php_uv.c b/php_uv.c index dde74df..3c896c5 100644 --- a/php_uv.c +++ b/php_uv.c @@ -4966,12 +4966,14 @@ PHP_FUNCTION(uv_exepath) */ PHP_FUNCTION(uv_cwd) { - char buffer[1024] = {0}; - size_t buffer_sz = sizeof(buffer); - - uv_cwd(buffer, buffer_sz); - buffer[buffer_sz] = '\0'; - + char buffer[MAXPATHLEN]; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + uv_cwd(buffer, MAXPATHLEN); + RETURN_STRING(buffer, 1); } /* }}} */ diff --git a/tests/999-uv_chdir.phpt b/tests/999-uv_chdir.phpt index b9641c8..58d8e83 100644 --- a/tests/999-uv_chdir.phpt +++ b/tests/999-uv_chdir.phpt @@ -2,7 +2,7 @@ Check for uv_chdir --FILE-- Date: Wed, 20 Aug 2014 21:57:34 +0800 Subject: [PATCH 08/15] Fixed off-by-one buffer issue in uv_exepath() --- php_uv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/php_uv.c b/php_uv.c index 3c896c5..923e380 100644 --- a/php_uv.c +++ b/php_uv.c @@ -4951,13 +4951,13 @@ PHP_FUNCTION(uv_hrtime) */ PHP_FUNCTION(uv_exepath) { - char buffer[1024] = {0}; - size_t buffer_sz; - - buffer_sz = sizeof(buffer); - uv_exepath(buffer, &buffer_sz); - buffer[buffer_sz] = '\0'; - + char buffer[MAXPATHLEN]; + size_t buffer_sz = sizeof(buffer) / sizeof(buffer[0]); + + if (uv_exepath(buffer, &buffer_sz) == UV_EINVAL) { + RETURN_FALSE; + } + RETURN_STRINGL(buffer, buffer_sz, 1); } /* }}} */ From bdaf5a0bb835c7d96881d4dac55ecb3c60e0f96a Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 08:31:25 +0800 Subject: [PATCH 09/15] Enabled http parser again --- config.m4 | 13 +------------ php_uv.c | 12 +++++++++--- php_uv.h | 4 ++++ uv.c | 7 +++++++ uv_http_parser.c | 47 +++++++++++++++-------------------------------- uv_http_parser.h | 23 +++++++++++++++++++++++ 6 files changed, 59 insertions(+), 47 deletions(-) diff --git a/config.m4 b/config.m4 index 56c145f..72222e0 100644 --- a/config.m4 +++ b/config.m4 @@ -44,7 +44,7 @@ if test $PHP_UV != "no"; then SOURCES="" if test $PHP_HTTPPARSER != "no"; then - SOURCES=" http-parser/http_parser.c" + SOURCES=" uv_http_parser.c http-parser/http_parser.c" AC_DEFINE([ENABLE_HTTPPARSER], [1], [ Enable http parser]) fi @@ -81,15 +81,4 @@ if test $PHP_UV != "no"; then ]) PHP_SUBST(UV_SHARED_LIBADD) - -# CFLAGS=" $CFLAGS -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement" - -# case $host in -# *darwin*) -# ;; -# *linux*) -# CFLAGS="$CFLAGS -lrt" -# esac - -# PHP_SUBST([CFLAGS]) fi diff --git a/php_uv.c b/php_uv.c index 923e380..6d82127 100644 --- a/php_uv.c +++ b/php_uv.c @@ -232,7 +232,6 @@ static int uv_lock_handle; static int uv_stdio_handle; - char *php_uv_resource_map[IS_UV_MAX] = { "uv_tcp", "uv_udp", @@ -2573,9 +2572,12 @@ PHP_MINIT_FUNCTION(uv) uv_loop_handle = zend_register_list_destructors_ex(destruct_uv_loop, NULL, PHP_UV_LOOP_RESOURCE_NAME, module_number); uv_sockaddr_handle = zend_register_list_destructors_ex(destruct_uv_sockaddr, NULL, PHP_UV_SOCKADDR_RESOURCE_NAME, module_number); uv_lock_handle = zend_register_list_destructors_ex(destruct_uv_lock, NULL, PHP_UV_LOCK_RESOURCE_NAME, module_number); -// uv_httpparser_handle = zend_register_list_destructors_ex(destruct_httpparser, NULL, PHP_UV_HTTPPARSER_RESOURCE_NAME, module_number); uv_stdio_handle = zend_register_list_destructors_ex(destruct_uv_stdio, NULL, PHP_UV_STDIO_RESOURCE_NAME, module_number); +#ifdef ENABLE_HTTPPARSER + register_httpparser(module_number); +#endif + return SUCCESS; } @@ -6509,10 +6511,14 @@ static zend_function_entry uv_functions[] = { PHP_FE(uv_signal_init, arginfo_uv_signal_init) PHP_FE(uv_signal_start, arginfo_uv_signal_start) PHP_FE(uv_signal_stop, arginfo_uv_signal_stop) +#ifdef ENABLE_HTTPPARSER + /* http parser */ + PHP_FE(uv_http_parser_init, arginfo_uv_http_parser_init) + PHP_FE(uv_http_parser_execute, arginfo_uv_http_parser_execute) +#endif {NULL, NULL, NULL} }; - PHP_MINFO_FUNCTION(uv) { char uv_version[20]; diff --git a/php_uv.h b/php_uv.h index 686c863..cc6dba1 100755 --- a/php_uv.h +++ b/php_uv.h @@ -32,6 +32,10 @@ #include "php.h" #include "uv.h" +#ifdef ENABLE_HTTPPARSER +#include "uv_http_parser.h" +#endif + #include "php_network.h" #include "php_streams.h" diff --git a/uv.c b/uv.c index 6094379..a64b9d7 100755 --- a/uv.c +++ b/uv.c @@ -183,6 +183,13 @@ static int php_uv_class_init(TSRMLS_D) zend_declare_class_constant_long(uv_class_entry, "PROCESS_WINDOWS_VERBATIM_ARGUMENTS", sizeof("PROCESS_WINDOWS_VERBATIM_ARGUMENTS")-1, UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "PROCESS_DETACHED", sizeof("PROCESS_DETACHED")-1, UV_PROCESS_DETACHED TSRMLS_CC); +#ifdef ENABLE_HTTPPARSER + /* http parser */ + zend_declare_class_constant_long(uv_class_entry, "HTTP_BOTH", sizeof("HTTP_BOTH")-1, HTTP_BOTH TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "HTTP_REQUEST", sizeof("HTTP_REQUEST")-1, HTTP_REQUEST TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); +#endif + #define PHP_UV_ERRNO_GEN(code_notused, name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC); UV_ERRNO_MAP(PHP_UV_ERRNO_GEN) #undef PHP_UV_ERRNO_GEN diff --git a/uv_http_parser.c b/uv_http_parser.c index 3c4ea28..ac18a71 100644 --- a/uv_http_parser.c +++ b/uv_http_parser.c @@ -1,9 +1,13 @@ +#include "uv_http_parser.h" + static int uv_httpparser_handle; -void static destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) +void destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) { php_http_parser_context *obj = (php_http_parser_context *)rsrc->ptr; - + + fprintf(stderr, "Destroying http parser\n"); + if (obj->headers) { zval_ptr_dtor(&obj->headers); } @@ -14,6 +18,11 @@ void static destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) efree(obj); } +void register_httpparser(int module_number) +{ + uv_httpparser_handle = zend_register_list_destructors_ex(destruct_httpparser, NULL, PHP_UV_HTTPPARSER_RESOURCE_NAME, module_number); +} + /* http parser callbacks */ static int on_message_begin(http_parser *p) { @@ -143,17 +152,6 @@ static int on_body_cb(http_parser *p, const char *at, size_t len) } /* end of callback */ -/* HTTP PARSER */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_init, 0, 0, 1) - ZEND_ARG_INFO(0, target) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_execute, 0, 0, 3) - ZEND_ARG_INFO(0, resource) - ZEND_ARG_INFO(0, buffer) - ZEND_ARG_INFO(0, setting) -ZEND_END_ARG_INFO() - /* {{{ proto resource uv_http_parser_init(long $target = UV::HTTP_REQUEST) */ PHP_FUNCTION(uv_http_parser_init) @@ -216,10 +214,10 @@ PHP_FUNCTION(uv_http_parser_execute) size_t nparsed = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "rs/a",&z_parser, &body, &body_len, &result) == FAILURE) { + "rs/a", &z_parser, &body, &body_len, &result) == FAILURE) { return; } - + ZEND_FETCH_RESOURCE(context, php_http_parser_context*, &z_parser, -1, PHP_UV_HTTPPARSER_RESOURCE_NAME, uv_httpparser_handle); if (context->finished == 1) { @@ -253,25 +251,10 @@ PHP_FUNCTION(uv_http_parser_execute) MAKE_STD_ZVAL(headers); ZVAL_ZVAL(headers, context->headers, 1, 0); + add_assoc_zval(headers, "VERSION", version); add_assoc_zval(result, "HEADERS", headers); - if (context->finished == 1) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(context->finished); } -// static zend_function_entry uv_functions[] = { - - /* http parser */ - PHP_FE(uv_http_parser_init, arginfo_uv_http_parser_init) - PHP_FE(uv_http_parser_execute, arginfo_uv_http_parser_execute) - -// php_uv_class_init - - zend_declare_class_constant_long(uv_class_entry, "HTTP_BOTH", sizeof("HTTP_BOTH")-1, HTTP_BOTH TSRMLS_CC); - zend_declare_class_constant_long(uv_class_entry, "HTTP_REQUEST", sizeof("HTTP_REQUEST")-1, HTTP_REQUEST TSRMLS_CC); - zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); - diff --git a/uv_http_parser.h b/uv_http_parser.h index a4d7a55..0379773 100644 --- a/uv_http_parser.h +++ b/uv_http_parser.h @@ -1,3 +1,9 @@ +#ifndef UV_HTTPPARSER_H +#define UV_HTTPPARSER_H + +#include "php.h" +#include "zend_exceptions.h" + #include "http_parser.h" typedef struct { @@ -15,3 +21,20 @@ typedef struct { #define PHP_UV_HTTPPARSER_RESOURCE_NAME "uv_httpparser" +void register_httpparser(int module_number); + +/* HTTP PARSER */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_init, 0, 0, 1) + ZEND_ARG_INFO(0, target) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_http_parser_execute, 0, 0, 3) + ZEND_ARG_INFO(0, resource) + ZEND_ARG_INFO(0, buffer) + ZEND_ARG_INFO(0, setting) +ZEND_END_ARG_INFO() + +PHP_FUNCTION(uv_http_parser_init); +PHP_FUNCTION(uv_http_parser_execute); + +#endif From 9308a0ed053736f220b0caf124bfc19704548f01 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 17:52:31 +0800 Subject: [PATCH 10/15] Removed debug code --- uv_http_parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/uv_http_parser.c b/uv_http_parser.c index ac18a71..2d7816b 100644 --- a/uv_http_parser.c +++ b/uv_http_parser.c @@ -6,8 +6,6 @@ void destruct_httpparser(zend_rsrc_list_entry *rsrc TSRMLS_DC) { php_http_parser_context *obj = (php_http_parser_context *)rsrc->ptr; - fprintf(stderr, "Destroying http parser\n"); - if (obj->headers) { zval_ptr_dtor(&obj->headers); } From 99c345c51d25c8440935bdfdccd7037207f8f1c5 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 17:58:13 +0800 Subject: [PATCH 11/15] Fixed test case to include version being returned as part of the parser results --- tests/999-uv_http_parser.phpt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/999-uv_http_parser.phpt b/tests/999-uv_http_parser.phpt index ba1c658..5e6dab6 100644 --- a/tests/999-uv_http_parser.phpt +++ b/tests/999-uv_http_parser.phpt @@ -53,7 +53,7 @@ uv_http_parser_execute($parser, $buffer, $result); var_dump($result); --EXPECT-- # Headers count -9 +10 # Headers values chobie.net Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0 @@ -80,7 +80,7 @@ array(5) { ["UPGRADE"]=> int(1) ["HEADERS"]=> - array(5) { + array(6) { ["UPGRADE"]=> string(9) "WebSocket" ["CONNECTION"]=> @@ -91,5 +91,7 @@ array(5) { string(18) "http://example.com" ["WEBSOCKET_PROTOCOL"]=> string(6) "sample" + ["VERSION"]=> + string(3) "1.1" } } From 89d25e6c145295b9d28d1c7b115c1096b5491438 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 17:58:30 +0800 Subject: [PATCH 12/15] Add 'sockets' dependency --- config.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.m4 b/config.m4 index 72222e0..34287ab 100644 --- a/config.m4 +++ b/config.m4 @@ -50,6 +50,8 @@ if test $PHP_UV != "no"; then PHP_NEW_EXTENSION(uv, php_uv.c uv.c $SOURCES, $ext_shared) + PHP_ADD_EXTENSION_DEP(uv, sockets) + if test $PHP_HTTPPARSER != "no"; then PHP_ADD_INCLUDE([$ext_srcdir/http-parser]) fi From c8aae4227b531b228156f3781d5eabd69b3a1538 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 18:00:16 +0800 Subject: [PATCH 13/15] Update Travis to enable http parser --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 762b037..b6a8dc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_script: - sudo apt-add-repository -y ppa:linuxjedi/ppa - sudo apt-get update - sudo apt-get -y install libuv-dev - - phpize && ./configure --with-uv && make && sudo make install + - phpize && ./configure --with-uv --enable-httpparser && make && sudo make install - echo "extension=uv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` notifications: From 8b5ffcfaa6f1db09ebaea31bdca3e887982069b9 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 18:14:03 +0800 Subject: [PATCH 14/15] Added 5.4 and 5.5 as targets, quiet the 'apt-get update' command --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b6a8dc0..14e70fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,13 @@ language: php php: + - 5.4 + - 5.5 - 5.6 before_script: - sudo apt-add-repository -y ppa:linuxjedi/ppa - - sudo apt-get update + - sudo apt-get update -qq - sudo apt-get -y install libuv-dev - phpize && ./configure --with-uv --enable-httpparser && make && sudo make install - echo "extension=uv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` From f2389fc530795e0e91007cfd5da580640cae4776 Mon Sep 17 00:00:00 2001 From: Tjerk Meesters Date: Thu, 21 Aug 2014 18:14:25 +0800 Subject: [PATCH 15/15] Added the '-lrt' CFLAG for linux arch back again --- config.m4 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.m4 b/config.m4 index 34287ab..8ca9311 100644 --- a/config.m4 +++ b/config.m4 @@ -82,5 +82,11 @@ if test $PHP_UV != "no"; then -L$UV_DIR/lib -lm ]) + case $host in + *linux*) + CFLAGS="$CFLAGS -lrt" + esac + + PHP_SUBST([CFLAGS]) PHP_SUBST(UV_SHARED_LIBADD) fi