mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
support very large numbers of DO connections.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35180 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
edebc8d4ea
commit
6e59f141f5
6 changed files with 90 additions and 39 deletions
|
@ -1414,6 +1414,8 @@ typedef struct {
|
|||
*/
|
||||
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count
|
||||
{
|
||||
NSInteger limit = *count;
|
||||
NSInteger pos = 0;
|
||||
NSMapEnumerator me;
|
||||
void *sock;
|
||||
GSMessageHandle *handle;
|
||||
|
@ -1421,19 +1423,18 @@ typedef struct {
|
|||
|
||||
M_LOCK(myLock);
|
||||
|
||||
/*
|
||||
* Make sure there is enough room in the provided array.
|
||||
*/
|
||||
NSAssert(*count > (int)NSCountMapTable(handles),
|
||||
NSInternalInconsistencyException);
|
||||
*count = NSCountMapTable(handles);
|
||||
|
||||
/*
|
||||
* Put in our listening socket.
|
||||
*/
|
||||
*count = 0;
|
||||
if (lDesc >= 0)
|
||||
{
|
||||
fds[(*count)++] = lDesc;
|
||||
*count = *count + 1;
|
||||
if (pos < limit)
|
||||
{
|
||||
fds[pos++] = lDesc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1444,9 +1445,10 @@ typedef struct {
|
|||
me = NSEnumerateMapTable(handles);
|
||||
while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle))
|
||||
{
|
||||
if (handle->recvPort == recvSelf)
|
||||
if (handle->recvPort == recvSelf
|
||||
&& pos < limit)
|
||||
{
|
||||
fds[(*count)++] = (int)(intptr_t)sock;
|
||||
fds[pos++] = (int)(intptr_t)sock;
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&me);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue