G/Morning All
Lights sometimes come on very slowly.
In addition to tweaking XS code to NetWare's select() to work (more anon) (finally) realised that IO::Select::INET was returning was an object and not the socket needed for select() (Doh!).

On the the XS problem that began here have (ftm) settled on the code as follows as (atm) it at least doesn't give NetWare abends (== segfault). NetWare's loadable modules have pre-defined (at build) stack space and pushing objects of largely unknown size onto the stack can break things.

sub can_read # Adapted from IO::Select
{
  my $vec  = shift;
  my $wait = shift;
  my @r    = $vec->handles;

  nw_select(\@r,undef,undef,$wait);

  @r;
}

Perl
------
XS
  /* Read Param array into int array */
  if ((SvROK(reads)) && (SvTYPE(SvRV(reads)) == SVt_PVAV)) {
    prda = (AV*) SvRV(reads);
    prds = &rdfds;
    FD_ZERO(prds);
    while (av_len((AV*)prda) >= 0) {
      if (rdfds.fd_count >= FD_SETSIZE)
        croak("Too many sockets passed to NeWare::select(rd): Max ", 
FD_SETSIZE);
      fd = (SV*)av_shift((AV*)prda);
      FD_SET(SvIV(fd), prds);
    }
    numfds += rdfds.fd_count;
  }
[...]
  /* Read int array and push back to Param array - int array always <= Param */
  if (prds != NULL) {
    av_clear((AV*)prda);
    for (i = 0 ; i < rdfds.fd_count ; i++) {
      sv_setpviv(fd, rdfds.fd_array[i]);
      av_push((AV*)prda, fd);
    }
  }

Modifying parameters is a computing 'taboo' so will return to stack passing return after I can get sockets out of ::INET and can find out how big the AV's are on the stack... unless the Sample 7 code comes by sooner. :-)

Thanks for the time and ideas.
FTM,
Norm

Reply via email to