Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl Lite接受filedescriptor,但不接受';不要释放它_Perl_Soap - Fatal编程技术网

Perl Lite接受filedescriptor,但不接受';不要释放它

Perl Lite接受filedescriptor,但不接受';不要释放它,perl,soap,Perl,Soap,我正在使用Perl(5.8.7)从Linux调用.net Web服务。 我正在使用SOAP::Lite库 基本的概念证明工作得很好,现在我正在现实世界中尝试它,在现实世界中我不得不多次调用Web服务。现在看起来web服务调用打开了一个文件,但没有释放文件描述符。默认的最大可用数量设置为256,并在程序停止后很快停止( 代码如下: # Create the soap client my $client = SOAP::Lite->new; # Get raw SOAP xml output

我正在使用Perl(5.8.7)从Linux调用.net Web服务。 我正在使用SOAP::Lite库

基本的概念证明工作得很好,现在我正在现实世界中尝试它,在现实世界中我不得不多次调用Web服务。现在看起来web服务调用打开了一个文件,但没有释放文件描述符。默认的最大可用数量设置为256,并在程序停止后很快停止(

代码如下:

# Create the soap client
my $client = SOAP::Lite->new;

# Get raw SOAP xml output
$client->outputxml(1);

# Set connection parameters
$client->uri($namespace);

# set the url in the proxy member. The keep_alive parameter is needed if user authentication
# is used, it is passed on to the user agent class to set up an authenticated HTTP session
$client->proxy($url, keep_alive => 1);

# Set the user credentials 
$client->transport->credentials("$host:$port", ''
    , $user
    , $password
);

# define the webservice method
$client->on_action( sub { return "$namespace$method" } );
my $soapmethod = SOAP::Data->name($method)
    ->attr({xmlns => $namespace});

# Generate the SOAP parameters and make the call
my @paramarray = ( \%paramhash );
my $ps = ${MakeSoapParameters(\@paramarray)};

# output the current number of filedescriptors used for this process
system("ls -l /proc/$$/fd | wc -l");
# Make the call
my $result = $client->call($soapmethod => $ps );
# output the current number of filedescriptors used for this process AFTER the call
system("ls -l /proc/$$/fd | wc -l");
如果我监视ls-l/proc/$$/fd | wc-l使用的文件描述符,我会注意到每次调用web服务时使用的文件描述符的数量都会增加


任何帮助或提示都将不胜感激。

我无法轻松测试这一点,但请尝试删除创建的SOAP对象。或者将此代码包装在函数中,以便在其超出范围时自动调用析构函数。

我认为这些文件描述符是套接字,系统通常需要一些时间来关闭TCP套接字。

解决了这一问题.
除此之外,我还需要学习更多关于Perl中对象创建、实例和销毁的知识…
只需创建一次SOAP::Lite对象,并在需要调用该Web服务时将其保留一段时间,就可以做到这一点。在为每次调用创建SOAP::Lite对象之前。
谢谢大家和我一起思考

my $client;

sub MakeTheCall
{
    if (! defined $client)
    {
        # Create the soap client
        my $client = SOAP::Lite->new;
        # Get raw SOAP xml output
        $client->outputxml(1);
        # Set connection parameters
        $client->uri($namespace);
        # set the url in the proxy member. The keep_alive parameter is needed if user authentication
        # is used, it is passed on to the user agent class to set up an authenticated HTTP session
        $client->proxy($url, keep_alive => 1);
        # Set the user credentials 
        $client->transport->credentials("$host:$port", ''
            , $user
            , $password);
    }

    # rest of the code here

}

在一行开头加逗号的人怎么了?这就是整个脚本吗?它是否以某种方式驻留在某个地方?你确定文件描述符不仅仅是你的客户端应该保持打开的套接字吗?不,我不确定。我甚至怀疑是这样的。显然,我需要做一些关闭或清理正在启动。我尝试过。让它超出范围,甚至设置为“undef”。没有太大变化。是的,这就是我现在怀疑的。这可能是由代理调用中的keep_alive标志引起的。我现在正在寻找方法,要么强制杀死这些连接,要么让所有web服务调用中的一个连接保持活动。后者可能是最好的选择圣。