Changeset 4d8f9e6 in rtems-libbsd


Ignore:
Timestamp:
Sep 17, 2018, 7:47:20 AM (13 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
c1e05b9ea378b2971e3d7704779112b4bc4296da, 4a77611a223ea883fb548679b516d326a020d447
Children:
ed40c80
Parents:
48cbe6c
git-author:
Sebastian Huber <sebastian.huber@…> (09/17/18 07:47:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/19/18 06:24:09)
Message:

mDNSResponder: Honour file descriptor maximum

Dynamically allocate a big enough file descriptor set for select(). A
better solution would be to use kqueue() instead of select().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mDNSResponder/mDNSPosix/mDNSPosix.c

    r48cbe6c r4d8f9e6  
    4141#include <arpa/inet.h>
    4242#include <time.h>                   // platform support for UTC time
     43#ifdef __rtems__
     44#include <sys/param.h>
     45#include <rtems/libio_.h>
     46#endif /* __rtems__ */
    4347
    4448#if USES_NETLINK
     
    7680
    7781// Note that static data is initialized to zero in (modern) C.
     82#ifndef __rtems__
    7883static fd_set gEventFDs;
     84#else /* __rtems__ */
     85static fd_set *gAllocatedEventFDs;
     86#define gEventFDs (*gAllocatedEventFDs)
     87#endif /* __rtems__ */
    7988static int gMaxFD;                              // largest fd in gEventFDs
    8089static GenLinkedList gEventSources;             // linked list of PosixEventSource's
     
    11571166{
    11581167    IfChangeRec     *pChgRec = (IfChangeRec*) context;
     1168#ifndef __rtems__
    11591169    fd_set readFDs;
     1170#else /* __rtems__ */
     1171    fd_set bigEnoughReadFDs[howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)];
     1172#define readFDs (*(&bigEnoughReadFDs[0]))
     1173#endif /* __rtems__ */
    11601174    mDNSu32 changedInterfaces = 0;
    11611175    struct timeval zeroTimeout = { 0, 0 };
     
    11641178    (void)filter; // Unused
    11651179
     1180#ifndef __rtems__
    11661181    FD_ZERO(&readFDs);
     1182#else /* __rtems__ */
     1183    memset(bigEnoughReadFDs, 0, sizeof(bigEnoughReadFDs));
     1184#endif /* __rtems__ */
    11671185    FD_SET(pChgRec->NotifySD, &readFDs);
    11681186
     
    12421260    mDNS_SetFQDN(m);
    12431261#ifdef __rtems__
     1262    if (err == mStatus_NoError) {
     1263        gAllocatedEventFDs = calloc(1, howmany(rtems_libio_number_iops, sizeof(fd_set) * 8));
     1264        if (gAllocatedEventFDs == NULL) err = mStatus_NoMemoryErr;
     1265    }
    12441266    if (err == mStatus_NoError) err = pthread_mutexattr_init(&attr);
    12451267    if (err == mStatus_NoError) err = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
     
    16861708        InitLinkedList(&gEventSources, offsetof(PosixEventSource, Next));
    16871709
     1710#ifndef __rtems__
    16881711    if (fd >= (int) FD_SETSIZE || fd < 0)
    16891712        return mStatus_UnsupportedErr;
     1713#endif /* __rtems__ */
    16901714    if (callback == NULL)
    16911715        return mStatus_BadParamErr;
     
    17671791                                  sigset_t *pSignalsReceived, mDNSBool *pDataDispatched)
    17681792{
     1793#ifndef __rtems__
    17691794    fd_set listenFDs = gEventFDs;
     1795#else /* __rtems__ */
     1796    fd_set bigEnoughListenFDs[howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)];
     1797#define listenFDs (*(&bigEnoughListenFDs[0]))
     1798    memcpy(bigEnoughListenFDs, gAllocatedEventFDs, sizeof(bigEnoughListenFDs));
     1799#endif /* __rtems__ */
    17701800    int fdMax = 0, numReady;
    17711801    struct timeval timeout = *pTimeout;
Note: See TracChangeset for help on using the changeset viewer.