SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] ext_poll problem


Chronological Thread 
  • From: rcl AT ihug.co.nz
  • To: discussion AT sctp.de
  • Subject: Re: [SCTP-Discussion] ext_poll problem
  • Date: Mon May 22 22:42:09 2006
  • List-id: SCTP Discussions <discussion.sctp.de>
  • Priority: normal

BTW, I forgot to include the patch I said I would.

Attached this time.

Ralph.


> Hi,
>
> poll() is not available on all systems, select is.
> Thank is why we build on that system call.
>
> Thomas, can you look at the other issues?
>
> Best regards
> Michael
>
> On May 22, 2006, at 1:30 AM,
> rcl AT ihug.co.nz
> wrote:
>
> > Hi,
> >
> > There is a problem with ext_poll in socketapi-1.7.0.
> >
> > The use of the getdtablesize() function is incorrect.
> >
> > E.g., on my system, it is returning 256, which is less
> > than the fake file descriptor values (around 1024) used
> > by sctplib. Then of course ext_select ignores the FDs
> > passed in.
> >
> > A minimal patch to fix this is below, although I think
> > it would be preferable to implement ext_poll directly,
> > rather than going through ext_select.
> >
> > There are someother minor problems with ext_select and
> > ext_poll (not fixed in my patch).
> >
> > 1. In ext_select, the logic for filling in the returned
> > bitmasks appears to be done twice - you clear out the
> > bitmasks, fill them, clear them out a second time and
> > fill them in again.
> >
> > 2. The return values from ext_poll and ext_select are
> > not quite correct.
> >
> > A successfull call to ext_poll is meant to return the
> > number of pollfd.revent fields filled in with non-zero
> > values. Currently it just returns what ext_select
> returns. >
> > A successfull call to ext_select is meant to return the
> > total number of bits set in the FDs on return. This
> > does not appear to be calculated correctly.
> >
> > 3. For the case where the FD sets are empty, the return
> > value is not correct. You fall back to doing:
> >
> > select(0,NULL,NULL,NULL,timeout);
> >
> > but ignore the return value (which may be -1, EINTR).
> >
> > 4. I think the getErrnoResult function used in the
> > errno_return macro, is not correct in the success case.
> > It sets errno=0. The Unix logic is to not change errno
> > on success, I believe.
> >
> > Cheers,
> > Ralph.
> >
> > PS. Is there a cvs (or other version control) of
> > sctplib and socketapi available?
> > _______________________________________________
> > discussion mailing list
> > discussion AT sctp.de
> > http://www.sctp.de/mailman/listinfo/discussion
> >
>
diff -u -r orig/socketapi-1.7.0/socketapi/sctpsocketwrapper.cc socketapi-1.7.0/socketapi/sctpsocketwrapper.cc
--- orig/socketapi-1.7.0/socketapi/sctpsocketwrapper.cc	Fri Sep 16 22:07:51 2005
+++ socketapi-1.7.0/socketapi/sctpsocketwrapper.cc	Mon May 22 17:01:02 2006
@@ -2808,7 +2808,7 @@
    }
 
    // ====== Prepare FD settings ============================================
-   int    fdcount = 0;
+   int    fdmax = 0;
    fd_set readfdset;
    fd_set writefdset;
    fd_set exceptfdset;
@@ -2826,9 +2826,11 @@
          FD_SET(fdlist[i].fd,&writefdset);
       }
       FD_SET(fdlist[i].fd,&exceptfdset);
-      fdcount++;
+      if (fdlist[i].fd >= fdmax) {
+          fdmax = fdlist[i].fd + 1;
+      }
    }
-   if(fdcount == 0) {
+   if(fdmax == 0) {
       return(0);
    }
    for(unsigned int i = 0;i < count;i++) {
@@ -2836,8 +2838,7 @@
    }
 
    // ====== Do ext_select() ================================================
-   const int tsize  = getdtablesize();
-   int       result = ext_select(tsize,&readfdset,&writefdset,&exceptfdset,to);
+   int       result = ext_select(fdmax,&readfdset,&writefdset,&exceptfdset,to);
    if(result < 0) {
       return(result);
    }



Archive powered by MHonArc 2.6.19+.

Top of page