VirtualBox

Changeset 16382 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Jan 29, 2009 5:16:22 PM (16 years ago)
Author:
vboxsync
Message:

ipcdUnix.cpp, xpcom/server.cpp: Fixed wrong loop. Changed my mind about trial error approach.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp

    r16371 r16382  
    4747#if defined(VBOX) && !defined(XP_OS2)
    4848# include <sys/resource.h>
     49# include <errno.h>
    4950#endif
    5051
     
    397398                PRFileDesc *clientFD;
    398399
    399                 // @todo : We need to handle errors from accept() especially something like 
     400                // @todo : We need to handle errors from accept() especially something like
    400401                //          EMFILE, which happens when we run out of file descriptors.
    401402                //          and puts XPCOMIPCD in a poll/accept endless loop!
     
    530531
    531532#if defined(VBOX) && !defined(XP_OS2)
    532         struct rlimit lim;
    533         if (getrlimit(RLIMIT_NOFILE, &lim) == 0)
    534         {
    535             int k = 10240;
    536             for (; k >= 2048; k -= 1024)
     533            // Increase the file table size to 10240 or as high as possible.
     534            struct rlimit lim;
     535            if (getrlimit(RLIMIT_NOFILE, &lim) == 0)
    537536            {
    538                 if (lim.rlim_cur < k)
     537                if (    lim.rlim_cur < 10240
     538                    &&  lim.rlim_cur < lim.rlim_max)
    539539                {
    540                     lim.rlim_cur = k;
    541                     if (setrlimit(RLIMIT_NOFILE, &lim) == 0)
    542                         break;
     540                    lim.rlim_cur = lim.rlim_max <= 10240 ? lim.rlim_max : 10240;
     541                    if (setrlimit(RLIMIT_NOFILE, &lim) == -1)
     542                        printf("WARNING: failed to increase file descriptor limit. (%d)\n", errno);
    543543                }
    544                 else
    545                     break;
    546544            }
    547             if (k <= 2048)
    548                 printf("WARNING: failed to increase file descriptor limit.\n");
    549         }
    550         else
    551             printf ("WARNING: failed to obtain per-process file-descriptor limit.\n");
     545            else
     546                printf("WARNING: failed to obtain per-process file-descriptor limit (%d).\n", errno);
    552547#endif
    553548
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette