-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction #19001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+67
−12
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on…
… object destruction Currently the resource is attached to the object and its refcount is increased. This means that the refcount to the resource is 2 instead of 1 as expected. A refcount of 2 is necessary in the current code because of how the error handling works: by using convert_to_null() the resource actually goes to rc_dtor_func(), dropping its refcount to 1. So on error the refcount is correct. To solve the issue, let `stream` conceptually be a borrow of the resource with refcount 1, and just use ZVAL_NULL() to prevent calling rc_dtor_func() on the resource.
- Loading branch information
commit 893ddd78e9cfad27d65b06b5a2b83863a6cb7a7f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
GH-18990 (SOAP HTTP socket not closing on object destruction) | ||
--INI-- | ||
soap.wsdl_cache_enabled=0 | ||
--EXTENSIONS-- | ||
soap | ||
--SKIPIF-- | ||
<?php | ||
require __DIR__.'/../../../standard/tests/http/server.inc'; | ||
http_server_skipif(); | ||
--FILE-- | ||
<?php | ||
require __DIR__.'/../../../standard/tests/http/server.inc'; | ||
|
||
$wsdl = file_get_contents(__DIR__.'/../server030.wsdl'); | ||
|
||
$soap = <<<EOF | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getItemsResponse><getItemsReturn SOAP-ENC:arrayType="ns1:Item[10]" xsi:type="ns1:ItemArray"><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text0</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text1</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text2</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text3</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text4</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text5</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text6</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text7</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text8</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text9</text></item></getItemsReturn></ns1:getItemsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> | ||
EOF; | ||
|
||
$responses = [ | ||
"data://text/plain,HTTP/1.1 200 OK\r\n". | ||
"Content-Type: text/xml;charset=utf-8\r\n". | ||
"Connection: Keep-Alive\r\n". | ||
"Content-Length: ".strlen($wsdl)."\r\n". | ||
"\r\n". | ||
$wsdl, | ||
|
||
"data://text/plain,HTTP/1.1 200 OK\r\n". | ||
"Content-Type: text/xml;charset=utf-8\r\n". | ||
"Connection: Keep-Alive\r\n". | ||
"Content-Length: ".strlen($soap)."\r\n". | ||
"\r\n". | ||
$soap, | ||
]; | ||
|
||
['pid' => $pid, 'uri' => $uri] = http_server($responses); | ||
|
||
$options = [ | ||
'trace' => false, | ||
'location' => $uri, | ||
]; | ||
|
||
$cnt = count(get_resources()); | ||
|
||
$client = new SoapClient($uri, $options); | ||
|
||
var_dump(count($client->getItems())); | ||
|
||
http_server_kill($pid); | ||
|
||
unset($client); | ||
var_dump(count(get_resources()) - $cnt); | ||
?> | ||
--EXPECT-- | ||
int(10) | ||
int(0) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the auto cleanup anymore ? (IDK what that function does)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That macro will also do the same thing that auto cleanup does:
php-src/main/php_streams.h
Lines 270 to 274 in 59dd0f8
Anyway, that "auto cleanup" name is a badly chosen name. It just means that the resource is exposed as a zval and will be cleaned up that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... that is indeed a bad name