Skip to content

Commit

Permalink
Merge pull request #95 from rryqszq4/development
Browse files Browse the repository at this point in the history
[pr] Add redis test and bug fix.
  • Loading branch information
rryqszq4 authored Mar 4, 2020
2 parents 0c7d6db + d3906c1 commit 8485f93
Show file tree
Hide file tree
Showing 65 changed files with 153 additions and 72 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ env:
NGINX_SRC_VERSION=1.12.2
- PHP_SRC_VERSION=7.1.33
NGINX_SRC_VERSION=1.12.2
- PHP_SRC_VERSION=7.2.27
- PHP_SRC_VERSION=7.2.28
NGINX_SRC_VERSION=1.12.2
- PHP_SRC_VERSION=7.3.14
- PHP_SRC_VERSION=7.3.15
NGINX_SRC_VERSION=1.12.2
- PHP_SRC_VERSION=7.4.2
- PHP_SRC_VERSION=7.4.3
NGINX_SRC_VERSION=1.12.2
- PHP_SRC_VERSION=7.2.27
- PHP_SRC_VERSION=7.2.28
NGINX_SRC_VERSION=1.12.2
NGINX_MODULE=DYNAMIC
services:
- memcache
- redis-server
- mysql
install:
- sudo cpanm -n Test::Nginx
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Installation
### Compile install

```sh
$ wget 'http://php.net/distributions/php-7.2.14.tar.gz'
$ tar xf php-7.2.14.tar.gz
$ cd php-7.2.14
$ wget 'http://php.net/distributions/php-7.3.10.tar.gz'
$ tar xf php-7.3.10.tar.gz
$ cd php-7.3.10

$ ./configure --prefix=/path/to/php --enable-embed
$ make && make install
Expand Down Expand Up @@ -160,7 +160,7 @@ http {
location = /ngx_socket2 {
default_type 'application/json;charset=UTF-8';
content_by_php {
content_by_php_block {
$fd = ngx_socket_create();
yield ngx_socket_connect($fd, "hq.sinajs.cn", 80);
Expand Down Expand Up @@ -265,6 +265,8 @@ Directives
* [body_filter_by_php_block](#body_filter_by_php_block)
* [php_keepalive](#php_keepalive)
* [php_set](#php_set)
* [php_socket_keepalive](#php_socket_keepalive)
* [php_socket_buffer_size](#php_socket_buffer_size)

php_ini_path
------------
Expand Down Expand Up @@ -420,6 +422,22 @@ php_set

Installs a php handler for the specified variable.

php_socket_keepalive
--------------------
**syntax:** `php_socket_keepalive`_`<size>`_

**default:** `0`

**context:** `http, server`

php_socket_buffer_size
----------------------
**syntax:** `php_socket_buffer_size`_`<size>`_

**default:** `4k`

**context:** `http, server, location, location if`

Nginx API for php
-----------------
* [ngx_exit](#ngx_exit)
Expand Down Expand Up @@ -758,6 +776,7 @@ Nginx non-blocking API for php
* [yield ngx_socket_close](#ngx_socket_close)
* [yield ngx_socket_send](#ngx_socket_send)
* [yield ngx_socket_recv](#ngx_socket_recv)
* [yield ngx_socket_recvpage](#ngx_socket_recvpage)
* [ngx_socket_recvsync](#ngx_socket_recvsync)
* [ngx_socket_clear](#ngx_socket_clear)

Expand Down Expand Up @@ -863,6 +882,17 @@ used to gather data from connected sockets.
buf is passed by reference, so it must be specified as a variable in the argument list.
Data read from socket by ngx_socket_recv() will be returned in buf.

ngx_socket_recvpage
-------------------
**syntax:** `( yield ngx_socket_recvpage(resource $socket, string &$buf, int &$rc) ) : int`

**parameters:**
- `socket: resource`
- `buf: string`
- `rc: int`

**context:** `rewrite_by_php*, access_by_php*, content_by_php*`

ngx_socket_recvsync
-------------------
**syntax:** `ngx_socket_recvsync(resource $socket, string &$buf, int $len) : int`
Expand Down Expand Up @@ -977,7 +1007,7 @@ NGX_HTTP_INSUFFICIENT_STORAGE | 507
Copyright and License
---------------------
```
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_core.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_core.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_directive.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_directive.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_fnthread.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_fnthread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_handler.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_handler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_header.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_header.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_keepalive.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_keepalive.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_module.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_module.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_output.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_output.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_request.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_request.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_sleep.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_sleep.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
11 changes: 10 additions & 1 deletion src/ngx_http_php_socket.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -565,6 +565,15 @@ ngx_http_php_socket_upstream_recv(ngx_http_request_t *r,
break;
}

#if 0
if (u->enabled_receive_page && rev->active && !rev->ready) {
ngx_php_debug("c->read->active: %d, c->read->ready: %d, c->read->eof: %d, c->read->write: %d, c->read->posted: %d\n",
c->read->active, c->read->ready, c->read->eof, c->read->write, c->read->posted);
Z_LVAL_P(ctx->recv_code) = NGX_AGAIN;
return NGX_AGAIN;
}
#endif

n = c->recv(c, b->last, size);
//ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%d", n);
ngx_php_debug("n = c->recv: %d\n", (int)n);
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_socket.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_socket_tcp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_socket_tcp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_util.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_variable.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_variable.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_zend_uthread.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_php_zend_uthread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_php_conf_file.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_php_conf_file.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
==============================================================================
Copyright (c) 2016-2019, rryqszq4 <[email protected]>
Copyright (c) 2016-2020, rryqszq4 <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
Loading

0 comments on commit 8485f93

Please sign in to comment.