Subject: | Memory leak when calling WS using wsdl |
There appears to be a slow memory leak when using a .wsdl file to make SOAP calls. Sample
code attached. The attached script grew from ~11MB at start to ~20MB RES size (VIRT went from
14MB to ~24MB) after running ~40,000 query loops. Confirmed this under both Ubuntu 6.06
LTS (perl 5.8.7) and Debian 4.0 STABLE (perl 5.8.8) with SOAP::Lite 0.71.07 installed from CPAN.
Attached code is .pl file, .wsdl, as well as a PHP-based server which runs from the same .wsdl.
Subject: | Authentication_test.php |
<?php
// Version 1.0
// This is a sample PHP to implement an authentication web service
// our servers will call your web service to Accept or Reject connections
// If code is to provide a starting point for a developer wanting to create their own
// authentication rules for their streaming.
//
// If you modify this script or create a new one make sure you keep your SOAP messages compatible
// with the definitions inside Authentication.wsdl
//
// If you change the WSDL definitions or SOAP structure the client may not understand how to
// interact with your code
// Create a soap server object based off the standard WSDL provided.
$server = new soapserver("Auth.wsdl", array('encoding'=>'UTF-8'));
/* function: Authenticate
* Purpose: This is the method that will be called during each connection
* Use one of the input parameters as a criteria to authenticate the client
*
* Comments: Keep the duration between entering and exiting this function to a minimum
* The client cannot begin streaming until you send back a result
* If an extremely long time has lapsed the web service client may also terminate the
* connection
*
* Inputs:
* (strings)account The name of the account associated with this request
* This could be useful if you have multiple accounts, otherwise is will
* always contain the same value.
*
* (strings)token This is the unique string that was passed into the Player
* This can be a alpha numeric and should not be predictable
*
* (strings)referrer This is the referrer passed to the server, usually this is the url
* to the .swf
*
* (strings)sourceURL This is the full URL being requested from the server
*
* (strings)ip This is the IP of the client connecting to the server
*
* Output:
* (int)0 Reject Access
* (int)1 Accept Access
*/
function Authenticate($account, $token, $referrer, $sourceurl, $ip)
{
// A very simple demonstration of how you can accept/reject connection on specific criteria
// In this case if the token is an even number we will allow access, if the number is odd we reject
if($token % 2 == 0) {
$retval = "1";
} else {
$retval = "0";
}
return $retval; // return ACCEPT(1) or REJECT(0)
}
// map the SOAP operation to the appropriate PHP function above
$server->addFunction("Authenticate");
// This is just some extra code to show what web service function is available if you browse this PHP
if ($_SERVER["REQUEST_METHOD"] == "POST") // If this is a post from the web service client then handle soap
{
header("Content-Type: text/xml"); // The client calling this code expects XML content-type
$server->handle(); // process the soap
}
else // this is probably a browser querying what function is available in this php
{
echo "This SOAP server can handle following functions:<br> ";
$functions = $server->getFunctions();
foreach($functions as $func)
{
echo $func . "<br>";
}
}
?>