RE: [Patch] File descriptor leak in ManagerBase - please advise.

2004-08-31 Thread Shapira, Yoav

Hi,
randomIS is set to null in the getBytes method.  But that's not as good
as an explicit close.  So I'll add an explicit close before setting
randomIS to null.  Your patch I don't like as much because it closes the
stream before the readLong method is invoked on it.

Yoav Shapira
Millennium Research Informatics


-Original Message-
From: Renato [mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 1:43 PM
To: [EMAIL PROTECTED]
Subject: [Patch] File descriptor leak in ManagerBase - please advise.

Hi all,

I running linux with tomcat 5.0.28. Today I have the
following error:

java.net.SocketException: Too many open files
at java.net.Socket.createImpl(Socket.java:331)
at java.net.Socket.init(Socket.java:304)
at java.net.Socket.init(Socket.java:124)
(...)

By checking with 'lsof -p tomcat_pid', I saw that
there thousands of opened /dev/urandom files.

I looked at the code and I found that in class
org/apache/catalina/session/ManagerBase.java, the
/dev/urandom is opened but apparently never closed...
( any reason ? )

I made this patch and it fixed my problem, with no
colateral effected so far...

---
../jakarta-tomcat-5.0.27-src/jakarta-tomcat-
catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.jav
a
 2004-06-17 22:11:20.0 -0300
+++
jakarta-tomcat-
catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.jav
a
2004-08-30 14:23:43.0 -0300
@@ -194,10 +194,12 @@
 try {
 File f=new File( devRandomSource );
 if( ! f.exists() ) return null;
-randomIS= new DataInputStream( new
FileInputStream(f));
+FileInputStream fin = new
FileInputStream(f);
+randomIS= new DataInputStream(fin);
 randomIS.readLong();
 if( log.isDebugEnabled() )
 log.debug( Opening  +
devRandomSource );
+fin.close();
 return randomIS;
 } catch (IOException ex){
 return null;
@@ -505,10 +507,12 @@
 devRandomSource=s;
 File f=new File( devRandomSource
);
 if( ! f.exists() ) return;
-randomIS= new DataInputStream(
new FileInputStream(f));
+FileInputStream fin = new
FileInputStream(f);
+randomIS= new
DataInputStream(fin);
 randomIS.readLong();
 if( log.isDebugEnabled() )
 log.debug( Opening  +
devRandomSource );
+   fin.close();
 } catch( IOException ex ) {
 randomIS=null;
 }

Any comment ?
Thanks for the attention
Renato - Brazil.




___
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [Patch] File descriptor leak in ManagerBase - please advise.

2004-08-31 Thread Renato
Hi,

I just saw your fix. I'll give it a try and let you
know.

Thanks.

--- Shapira, Yoav [EMAIL PROTECTED] wrote:

 
 Hi,
 randomIS is set to null in the getBytes method.  But
 that's not as good
 as an explicit close.  So I'll add an explicit close
 before setting
 randomIS to null.  Your patch I don't like as much
 because it closes the
 stream before the readLong method is invoked on it.
 
 Yoav Shapira
 Millennium Research Informatics
 
 
 -Original Message-
 From: Renato [mailto:[EMAIL PROTECTED]
 Sent: Monday, August 30, 2004 1:43 PM
 To: [EMAIL PROTECTED]
 Subject: [Patch] File descriptor leak in
 ManagerBase - please advise.
 
 Hi all,
 
 I running linux with tomcat 5.0.28. Today I have
 the
 following error:
 
 java.net.SocketException: Too many open files
 at
 java.net.Socket.createImpl(Socket.java:331)
 at java.net.Socket.init(Socket.java:304)
 at java.net.Socket.init(Socket.java:124)
 (...)
 
 By checking with 'lsof -p tomcat_pid', I saw that
 there thousands of opened /dev/urandom files.
 
 I looked at the code and I found that in class
 org/apache/catalina/session/ManagerBase.java, the
 /dev/urandom is opened but apparently never
 closed...
 ( any reason ? )
 
 I made this patch and it fixed my problem, with no
 colateral effected so far...
 
 ---
 ../jakarta-tomcat-5.0.27-src/jakarta-tomcat-

catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.jav
 a
  2004-06-17 22:11:20.0 -0300
 +++
 jakarta-tomcat-

catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.jav
 a
 2004-08-30 14:23:43.0 -0300
 @@ -194,10 +194,12 @@
  try {
  File f=new File( devRandomSource
 );
  if( ! f.exists() ) return null;
 -randomIS= new DataInputStream( new
 FileInputStream(f));
 +FileInputStream fin = new
 FileInputStream(f);
 +randomIS= new
 DataInputStream(fin);
  randomIS.readLong();
  if( log.isDebugEnabled() )
  log.debug( Opening  +
 devRandomSource );
 +fin.close();
  return randomIS;
  } catch (IOException ex){
  return null;
 @@ -505,10 +507,12 @@
  devRandomSource=s;
  File f=new File(
 devRandomSource
 );
  if( ! f.exists() ) return;
 -randomIS= new DataInputStream(
 new FileInputStream(f));
 +FileInputStream fin = new
 FileInputStream(f);
 +randomIS= new
 DataInputStream(fin);
  randomIS.readLong();
  if( log.isDebugEnabled() )
  log.debug( Opening  +
 devRandomSource );
 +   fin.close();
  } catch( IOException ex ) {
  randomIS=null;
  }
 
 Any comment ?
 Thanks for the attention
 Renato - Brazil.
 
 
 
 
 ___
 Do you Yahoo!?
 Win 1 of 4,000 free domain names from Yahoo! Enter
 now.
 http://promotions.yahoo.com/goldrush
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 
 
 This e-mail, including any attachments, is a
 confidential business communication, and may contain
 information that is confidential, proprietary and/or
 privileged.  This e-mail is intended only for the
 individual(s) to whom it is addressed, and may not
 be saved, copied, printed, disclosed or used by
 anyone else.  If you are not the(an) intended
 recipient, please immediately delete this e-mail
 from your computer system and notify the sender. 
 Thank you.
 
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 




__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]