2009-07-30 19 views
0

私はLinuxから.net webserviceをPerl(5.8.7)を使って呼び出しています。 私はSOAP :: Liteライブラリを使用しています。SOAP :: Liteはfiledescriptorを取りますが、それを解放しません

概念の基本的な証明はうまくいきました。今では、Webサービスを何度も呼び出さなければならない現実世界で試しています。今度は、Webサービス呼び出しがファイルをオープンするが、ファイル記述子を解放しないように見える。使用可能なデフォルトの最大数は256に設定されていますが、それ以降はすぐにプログラムが終了します。私はLS -l/procの/ $$/fdに使用されるファイルディスクリプタを監視する場合

# 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"); 

|トイレ-l私はすべてを上がるために使用されるファイル記述子の数に気づく::(

は、ここでは、コードです時間は、私は、Webサービスの呼び出しを行う。

任意のヘルプやヒントをいただければ幸いです。私はこれを簡単にテストするが、作成したSOAPオブジェクトを削除してみてください。または、ときにそれをので、関数内のコードをラップすることはできません

+1

コンマを行頭に置いた人は何ですか? –

+1

これはスクリプト全体ですか?どういうわけかどこかに居住していますか? –

+0

あなたは、ファイル記述子があなたのクライアントが開いたままにしておくべきソケットだけではないと確信していますか? – innaM

答えて

0

解決しました。
私はオブジェクトの作成、インスタンス、および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 

} 
0

スコープ外に出ると、デストラクタは自動的に呼び出されます。

+0

私はそれを試みました。範囲外になったり、undefに設定することさえできます。あまり変わっていない。 –

0

これらのファイル記述子はソケットだと思うし、通常はシステムがTCPソケットをシャットダウンするまでに時間がかかります。

+0

うん、それは私が現時点で疑うところだ。おそらく、プロキシ呼び出しのkeep_aliveフラグが原因です。私は今、これらの接続を強制的に強制終了する方法、またはすべてのWebサービス呼び出しに対してただ1つを維持する方法を見ています。後者はおそらく最高です。 –

関連する問題