f



[ace-users] Re: [tao-users] ACE::set_handle_limit broken

Hi Eider,

Thanks for the PRF!

"Eider Oliveira" <eider.oliveira@gmail.com> wrote in message
news:<2e53f4ef0409021132f3de615@mail.gmail.com>...
>     ACE VERSION: 5.4.1
> 
>     HOST MACHINE and OPERATING SYSTEM: Linux
> 
> 
> When at  Select_Reactor.cpp:550
>   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
> 
>   // First try to open the Reactor with the hard-coded default.
>   if (this->open
(ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
>                   0,
>                   sh,
>                   tq,
>                   disable_notify_pipe,
>                   notify) == -1)
>  
> open is called, the value
> ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE (1024)
> is lowering the rlimits for the entire app.
> 
> I don't find a way to change this DEFAULT_SIZE

Please see sidebar 20 on page 92 in C++NPv2. See
http://www.riverace.com/acebooks/ for more information on the books.

Best regards,

-Steve










0
Steve
9/3/2004 2:20:57 PM
comp.soft-sys.ace 20326 articles. 1 followers. marlow.andrew (167) is leader. Post Follow

4 Replies
661 Views

Similar Articles

[PageSpeed] 15

Hi Steve,

 This isn't the case. I don't want to use the Select Reactor with more
then FD_SIZE I/O handles.  It's not a problem Select_Reactor limit the
number of event handlers. It 's a problem it reduce the app limit
(setrlimit) to open files.

  I just want to open more files in the app, and I won't use thes fd
in any select.

  The problem is the Select_Reactor is reducing the resource limit to
FD_SIZE, avoiding me to open the files I need.

  


On Fri, 3 Sep 2004 08:49:57 -0400, Steve Huston <shuston@riverace.com> wrote:
> Hi Eider,
> 
> Thanks for the PRF!
> 
> "Eider Oliveira" <eider.oliveira@gmail.com> wrote in message
> news:<2e53f4ef0409021132f3de615@mail.gmail.com>...
> >     ACE VERSION: 5.4.1
> >
> >     HOST MACHINE and OPERATING SYSTEM: Linux
> >
> >
> > When at  Select_Reactor.cpp:550
> >   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
> >
> >   // First try to open the Reactor with the hard-coded default.
> >   if (this->open
> (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
> >                   0,
> >                   sh,
> >                   tq,
> >                   disable_notify_pipe,
> >                   notify) == -1)
> >
> > open is called, the value
> > ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE (1024)
> > is lowering the rlimits for the entire app.
> >
> > I don't find a way to change this DEFAULT_SIZE
> 
> Please see sidebar 20 on page 92 in C++NPv2. See
> http://www.riverace.com/acebooks/ for more information on the books.
> 
> Best regards,
> 
> -Steve
> 
> 



















-- 
Eider Oliveira
ICQ - 26992792

0
Eider
9/3/2004 5:43:57 PM
Hi,

   follow the patch:

// Set the number of currently open handles in the process.
//
// If NEW_LIMIT == -1 set the limit to the maximum allowable.
// Otherwise, set it to be the value of NEW_LIMIT.

int
ACE::set_handle_limit (int new_limit)
{
  ACE_TRACE ("ACE::set_handle_limit");
  int cur_limit = ACE::max_handles ();
  int max_limit = cur_limit;

  if (cur_limit == -1)
    return -1;

#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
  struct rlimit rl;

  ACE_OS::memset ((void *) &rl, 0, sizeof rl);
  int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
  if (r == 0)
    max_limit = rl.rlim_max;
#endif /* ACE_LACKS_RLIMIT */

  if (new_limit == -1)
    new_limit = max_limit;

  if (new_limit < 0)
    {
      errno = EINVAL;
      return -1;
    }
  else if (new_limit > cur_limit)
    {
#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
      rl.rlim_cur = new_limit;
      return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
#else
      // Must return EINVAL errno.
      ACE_NOTSUP_RETURN (-1);
#endif /* ACE_LACKS_RLIMIT */
    }
     // There is no reason to lower the limit
     return 0;
}


On Wed, 8 Sep 2004 09:47:54 -0400, Steve Huston <shuston@riverace.com> wrote:
> Ah, ok. I misunderstood.
> 
> The problem could be resolved using our support services if you like.
> Alternately, if you develop a patch and post it to ace-users, someone
> will probably be able to take care of integrating it.
> 
> Best regards,
> 
> -Steve
> 
> --
> Steve Huston, Riverace Corporation
> Adding Service to Open Source Software
> ACE book info at http://www.riverace.com/acebooks/
> 
> 
> 
> > -----Original Message-----
> > From: Eider Oliveira [mailto:eider.oliveira@gmail.com]
> > Sent: Friday, September 03, 2004 1:31 PM
> > To: Steve Huston
> > Cc: ace-users@cs.wustl.edu; tao-users@cs.wustl.edu
> > Subject: Re: [ace-users] Re: [tao-users] ACE::set_handle_limit
> broken
> >
> >
> > Hi Steve,
> >
> >  This isn't the case. I don't want to use the Select Reactor with
> more
> > then FD_SIZE I/O handles.  It's not a problem Select_Reactor limit
> the
> > number of event handlers. It 's a problem it reduce the app limit
> > (setrlimit) to open files.
> >
> >   I just want to open more files in the app, and I won't use thes fd
> > in any select.
> >
> >   The problem is the Select_Reactor is reducing the resource limit
> to
> > FD_SIZE, avoiding me to open the files I need.
> >
> >
> >
> >
> > On Fri, 3 Sep 2004 08:49:57 -0400, Steve Huston
> > <shuston@riverace.com> wrote:
> > > Hi Eider,
> > >
> > > Thanks for the PRF!
> > >
> > > "Eider Oliveira" <eider.oliveira@gmail.com> wrote in message
> > > news:<2e53f4ef0409021132f3de615@mail.gmail.com>...
> > > >     ACE VERSION: 5.4.1
> > > >
> > > >     HOST MACHINE and OPERATING SYSTEM: Linux
> > > >
> > > >
> > > > When at  Select_Reactor.cpp:550
> > > >   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
> > > >
> > > >   // First try to open the Reactor with the hard-coded default.
> > > >   if (this->open
> > > (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
> > > >                   0,
> > > >                   sh,
> > > >                   tq,
> > > >                   disable_notify_pipe,
> > > >                   notify) == -1)
> > > >
> > > > open is called, the value
> > > >
> > ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE (1024)
> > > > is lowering the rlimits for the entire app.
> > > >
> > > > I don't find a way to change this DEFAULT_SIZE
> > >
> > > Please see sidebar 20 on page 92 in C++NPv2. See
> > > http://www.riverace.com/acebooks/ for more information on the
> books.
> > >
> > > Best regards,
> > >
> > > -Steve
> > >
> > >
> >
> >
> >
> > --
> > Eider Oliveira
> > ICQ - 26992792
> >
> 
> 










































-- 
Eider Oliveira
ICQ - 26992792

0
Eider
9/9/2004 11:54:06 AM
Hi Eider,

>>    follow the patch:
>> 
>> // Set the number of currently open handles in the process.
>> //
>> // If NEW_LIMIT == -1 set the limit to the maximum allowable.
>> // Otherwise, set it to be the value of NEW_LIMIT.
>> 
>> int
>> ACE::set_handle_limit (int new_limit)
>> {
>>   ACE_TRACE ("ACE::set_handle_limit");
>>   int cur_limit = ACE::max_handles ();
>>   int max_limit = cur_limit;
>> 
>>   if (cur_limit == -1)
>>     return -1;
>> 
>> #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
>>   struct rlimit rl;
>> 
>>   ACE_OS::memset ((void *) &rl, 0, sizeof rl);
>>   int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
>>   if (r == 0)
>>     max_limit = rl.rlim_max;
>> #endif /* ACE_LACKS_RLIMIT */
>> 
>>   if (new_limit == -1)
>>     new_limit = max_limit;
>> 
>>   if (new_limit < 0)
>>     {
>>       errno = EINVAL;
>>       return -1;
>>     }
>>   else if (new_limit > cur_limit)
>>     {
>> #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
>>       rl.rlim_cur = new_limit;
>>       return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
>> #else
>>       // Must return EINVAL errno.
>>       ACE_NOTSUP_RETURN (-1);
>> #endif /* ACE_LACKS_RLIMIT */
>>     }
>>      // There is no reason to lower the limit
>>      return 0;
>> }

I've applied this patch, thanks!

Doug






































-- 
Dr. Douglas C. Schmidt, Professor           TEL: (615) 343-8197
Electrical Engineering and Computer Science FAX: (615) 343-7440
Vanderbilt University                       WEB: www.cs.wustl.edu/~schmidt/
Nashville, TN 37203                         NET: d.schmidt@vanderbilt.edu

0
Douglas
9/14/2004 1:19:33 AM
Hi Eider,

        After looking at this some more I don't think it's the right
fix.  There are situations where applications need to be able to lower
the number of I/O handles in a process via the ACE::set_handle_limit()
method, so changing this method to ignore new_limit values that are
less than cur_limit will break these applications.  I think the "Right
Thing"[TM] to do here is to enhance the ACE::set_handle_limit() method
as follows:

  /**
   * Reset the limit on the number of open handles.  If @a new_limit
   * == -1 set the limit to the maximum allowable.  Otherwise, set
   * the limit value to @a new_limit.  If @a increase_limit_only is 
   * non-0 then only allow increases to the limit.
   */
  extern ACE_Export int set_handle_limit (int new_limit = -1,
                                          int increase_limit_only = 0);

and change the ACE_Select_Reactor_Handler_Repository::open () method
in Select_Reactor_Base.cpp to

  // Try to increase the number of handles if <size> is greater than
  // the current limit.
  return ACE::set_handle_limit (static_cast<int> (size), 1);

Please take a look and let me know if this is ok.  The files are at

http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ace/ACE.h
http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ace/ACE.cpp
http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ace/Select_Reactor_Base.cpp

Thanks,

        Doug

>>    follow the patch:
>> 
>> // Set the number of currently open handles in the process.
>> //
>> // If NEW_LIMIT == -1 set the limit to the maximum allowable.
>> // Otherwise, set it to be the value of NEW_LIMIT.
>> 
>> int
>> ACE::set_handle_limit (int new_limit)
>> {
>>   ACE_TRACE ("ACE::set_handle_limit");
>>   int cur_limit = ACE::max_handles ();
>>   int max_limit = cur_limit;
>> 
>>   if (cur_limit == -1)
>>     return -1;
>> 
>> #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
>>   struct rlimit rl;
>> 
>>   ACE_OS::memset ((void *) &rl, 0, sizeof rl);
>>   int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl);
>>   if (r == 0)
>>     max_limit = rl.rlim_max;
>> #endif /* ACE_LACKS_RLIMIT */
>> 
>>   if (new_limit == -1)
>>     new_limit = max_limit;
>> 
>>   if (new_limit < 0)
>>     {
>>       errno = EINVAL;
>>       return -1;
>>     }
>>   else if (new_limit > cur_limit)
>>     {
>> #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
>>       rl.rlim_cur = new_limit;
>>       return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
>> #else
>>       // Must return EINVAL errno.
>>       ACE_NOTSUP_RETURN (-1);
>> #endif /* ACE_LACKS_RLIMIT */
>>     }
>>      // There is no reason to lower the limit
>>      return 0;
>> }
>> 
>> 
>> On Wed, 8 Sep 2004 09:47:54 -0400, Steve Huston <shuston@riverace.com> wrote:
>> > Ah, ok. I misunderstood.
>> > 
>> > The problem could be resolved using our support services if you like.
>> > Alternately, if you develop a patch and post it to ace-users, someone
>> > will probably be able to take care of integrating it.
>> > 
>> > Best regards,
>> > 
>> > -Steve
>> > 
>> > --
>> > Steve Huston, Riverace Corporation
>> > Adding Service to Open Source Software
>> > ACE book info at http://www.riverace.com/acebooks/
>> > 
>> > 
>> > 
>> > > -----Original Message-----
>> > > From: Eider Oliveira [mailto:eider.oliveira@gmail.com]
>> > > Sent: Friday, September 03, 2004 1:31 PM
>> > > To: Steve Huston
>> > > Cc: ace-users@cs.wustl.edu; tao-users@cs.wustl.edu
>> > > Subject: Re: [ace-users] Re: [tao-users] ACE::set_handle_limit
>> > broken
>> > >
>> > >
>> > > Hi Steve,
>> > >
>> > >  This isn't the case. I don't want to use the Select Reactor with
>> > more
>> > > then FD_SIZE I/O handles.  It's not a problem Select_Reactor limit
>> > the
>> > > number of event handlers. It 's a problem it reduce the app limit
>> > > (setrlimit) to open files.
>> > >
>> > >   I just want to open more files in the app, and I won't use thes fd
>> > > in any select.
>> > >
>> > >   The problem is the Select_Reactor is reducing the resource limit
>> > to
>> > > FD_SIZE, avoiding me to open the files I need.
>> > >
>> > >
>> > >
>> > >
>> > > On Fri, 3 Sep 2004 08:49:57 -0400, Steve Huston
>> > > <shuston@riverace.com> wrote:
>> > > > Hi Eider,
>> > > >
>> > > > Thanks for the PRF!
>> > > >
>> > > > "Eider Oliveira" <eider.oliveira@gmail.com> wrote in message
>> > > > news:<2e53f4ef0409021132f3de615@mail.gmail.com>...
>> > > > >     ACE VERSION: 5.4.1
>> > > > >
>> > > > >     HOST MACHINE and OPERATING SYSTEM: Linux
>> > > > >
>> > > > >
>> > > > > When at  Select_Reactor.cpp:550
>> > > > >   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
>> > > > >
>> > > > >   // First try to open the Reactor with the hard-coded default.
>> > > > >   if (this->open
>> > > > (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
>> > > > >                   0,
>> > > > >                   sh,
>> > > > >                   tq,
>> > > > >                   disable_notify_pipe,
>> > > > >                   notify) == -1)
>> > > > >
>> > > > > open is called, the value
>> > > > >
>> > > ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE (1024)
>> > > > > is lowering the rlimits for the entire app.
>> > > > >
>> > > > > I don't find a way to change this DEFAULT_SIZE
>> > > >
>> > > > Please see sidebar 20 on page 92 in C++NPv2. See
>> > > > http://www.riverace.com/acebooks/ for more information on the
>> > books.
>> > > >
>> > > > Best regards,
>> > > >
>> > > > -Steve
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Eider Oliveira
>> > > ICQ - 26992792
>> > >
>> > 
>> > 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Eider Oliveira
>> ICQ - 26992792
>> 
























































































































































-- 
Dr. Douglas C. Schmidt, Professor           TEL: (615) 343-8197
Electrical Engineering and Computer Science FAX: (615) 343-7440
Vanderbilt University                       WEB: www.cs.wustl.edu/~schmidt/
Nashville, TN 37203                         NET: d.schmidt@vanderbilt.edu

0
Douglas
9/14/2004 1:36:13 AM
Reply: