From 5b277c4da0d9fb8bfb59186b61a884aaafffb861 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 11 Mar 2010 16:37:24 +0000 Subject: add backlock socket context option for stream_socket_server(), which had a hardcoded backlog of 5 at two occurrances --- main/streams/transports.c | 15 ++++++++++++++- main/streams/xp_socket.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/main/streams/transports.c b/main/streams/transports.c index 42ac54d488..31b45f7018 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -157,7 +157,20 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int ERR_RETURN(error_string, error_text, "bind() failed: %s"); failed = 1; } else if (flags & STREAM_XPORT_LISTEN) { - if (0 != php_stream_xport_listen(stream, 5, &error_text TSRMLS_CC)) { + zval **zbacklog = NULL; + int backlog = 32; + + if (stream->context && php_stream_context_get_option(stream->context, "socket", "backlog", &zbacklog) == SUCCESS) { + zval *ztmp = *zbacklog; + + convert_to_long_ex(&ztmp); + backlog = Z_LVAL_P(ztmp); + if (ztmp != *zbacklog) { + zval_ptr_dtor(&ztmp); + } + } + + if (0 != php_stream_xport_listen(stream, backlog, &error_text TSRMLS_CC)) { ERR_RETURN(error_string, error_text, "listen() failed: %s"); failed = 1; } diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 7d993f11a6..3b1eb87a30 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -324,7 +324,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void switch (xparam->op) { case STREAM_XPORT_OP_LISTEN: - xparam->outputs.returncode = (listen(sock->socket, 5) == 0) ? 0: -1; + xparam->outputs.returncode = (listen(sock->socket, xparam->inputs.backlog) == 0) ? 0: -1; return PHP_STREAM_OPTION_RETURN_OK; case STREAM_XPORT_OP_GET_NAME: -- cgit v1.2.1 From 3f15f8f4e3711358808783e839b1d6e8c281e8de Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Thu, 11 Mar 2010 19:50:04 +0000 Subject: Fix build (see r296062) --- ext/pgsql/pgsql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 228fe4d18c..43bd32b8f5 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3303,7 +3303,7 @@ PHP_FUNCTION(pg_lo_read_all) tbytes = 0; while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, PGSQL_LO_READ_BUF_SIZE))>0) { - php_body_write(buf, nbytes TSRMLS_CC); + PHPWRITE(buf, nbytes); tbytes += nbytes; } RETURN_LONG(tbytes); -- cgit v1.2.1 From 321ca32642fcfd68b5b89052239ff8139286ed10 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Fri, 12 Mar 2010 00:27:57 +0000 Subject: New and improved DBA tests --- ext/dba/tests/dba012.phpt | 42 +++++++++++++++++++++++ ext/dba/tests/dba013.phpt | 27 +++++++++++++++ ext/dba/tests/dba014.phpt | 27 +++++++++++++++ ext/dba/tests/dba015.phpt | 76 ++++++++++++++++++++++++++++++++++++++++++ ext/dba/tests/dba_db4_003.phpt | 5 +++ 5 files changed, 177 insertions(+) create mode 100644 ext/dba/tests/dba012.phpt create mode 100644 ext/dba/tests/dba013.phpt create mode 100644 ext/dba/tests/dba014.phpt create mode 100644 ext/dba/tests/dba015.phpt diff --git a/ext/dba/tests/dba012.phpt b/ext/dba/tests/dba012.phpt new file mode 100644 index 0000000000..821c4e2aba --- /dev/null +++ b/ext/dba/tests/dba012.phpt @@ -0,0 +1,42 @@ +--TEST-- +DBA dba.default_handler tests +--SKIPIF-- + +--INI-- +dba.default_handler=flatfile +--FILE-- + +--CLEAN-- + +--EXPECTF-- +database handler: flatfile +Test 1 + +Warning: ini_set(): No such handler: does_not_exist in %sdba012.php on line %d +resource(%d) of type (dba) +Test 2 + +Warning: dba_open(%stest0.dbm,n): No default handler selected in %sdba012.php on line %d +bool(false) diff --git a/ext/dba/tests/dba013.phpt b/ext/dba/tests/dba013.phpt new file mode 100644 index 0000000000..bf95642e9d --- /dev/null +++ b/ext/dba/tests/dba013.phpt @@ -0,0 +1,27 @@ +--TEST-- +DBA with array key with empty array +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +database handler: %s + +Catchable fatal error: dba_insert(): Key does not have exactly two elements: (key, name) in %sdba013.php on line %d diff --git a/ext/dba/tests/dba014.phpt b/ext/dba/tests/dba014.phpt new file mode 100644 index 0000000000..7e52be7c3a --- /dev/null +++ b/ext/dba/tests/dba014.phpt @@ -0,0 +1,27 @@ +--TEST-- +DBA with array key with array containing too many elements +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +database handler: %s + +Catchable fatal error: dba_insert(): Key does not have exactly two elements: (key, name) in %sdba014.php on line %d diff --git a/ext/dba/tests/dba015.phpt b/ext/dba/tests/dba015.phpt new file mode 100644 index 0000000000..9f560c5b2f --- /dev/null +++ b/ext/dba/tests/dba015.phpt @@ -0,0 +1,76 @@ +--TEST-- +DBA with persistent connections +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--XFAIL-- +Test 6 crashes in flatfile_findkey with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278 +--EXPECTF-- +database handler: flatfile +Test 1 +This is a test insert 1 +Test 2 +resources are different +Test 3 - fetch both rows from second resource +This is a test insert 1 +This is a test insert 2 +Test 4 - fetch both rows from first resource +This is a test insert 1 +This is a test insert 2 +Test 5 - close 2nd resource +resource(%d) of type (dba persistent) +resource(%d) of type (Unknown) +Test 6 - query after closing 2nd resource +This is a test insert 1 +This is a test insert 2 +===DONE=== diff --git a/ext/dba/tests/dba_db4_003.phpt b/ext/dba/tests/dba_db4_003.phpt index 084bff8d87..7e8568c085 100644 --- a/ext/dba/tests/dba_db4_003.phpt +++ b/ext/dba/tests/dba_db4_003.phpt @@ -26,6 +26,10 @@ if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) { echo "Error creating $db_filename\n"; } +// Check the file still exists +$s = file_get_contents($db_filename); +echo "$s\n"; + ?> --CLEAN--