This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Select problem found (I think) with GoAhead


Hello All,

I've been having trouble with eCos and the GoAhead web
server with blocks of memory becoming invalidated.

I found that in the GoAhead web server code there is a function
called socketSelect which has the calculation of

nwords = (socketHighestFd + NFDBITS) / NFDBITS;

This seems to calculate nwords to be 1 and then it has
the calculation:

len = nwords * sizeof(int);

which happends to be 4 it seems in my case. Then the
fd_masks are malloced using the len ie:

readFds = balloc(B_L, len);

so we have 4 bytes for readFds. Now latter on a select call
happends like:

   nEvents = select(socketHighestFd + 1, (fd_set *) readFds,
      (fd_set *) writeFds, (fd_set *) exceptFds, &tv);

the select call maps down to the call:

cyg_select(int nfd, fd_set *in, fd_set *out, fd_set *ex,
                    struct timeval *tv, cyg_bool_t abortable)

which defines:

fd_set in_res, out_res, ex_res;  // Result sets

unfortunatly later on if it finds something it does:

 memcpy(in, &in_res, sizeof(in_res));

the size of in_res being 32. which blats over the memory in
the readFds.

This is using the latest eCos cvs with the latest tcp stack from cvs and

the latest 2.1 GoAhead server.

To get GoAhead to compiler with eCos I had to add:

#define     NFDBITS        __NFDBITS

So which bit should I change the calculation? The fd_mask to
an fd_set? The NFDBITS definition or is there something that
I'm missing here? Why does the socketSelect function not
use FD_SET, FD_ISSET etc?

Many thanks,
Col.

--
===========================================
Colin Ford               PipingHot Networks
Software Engineer        +44 (0)1364 655510




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]