Changeset b9861d in git for Singular


Ignore:
Timestamp:
Mar 26, 2024, 3:30:16 PM (8 weeks ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
c557548eb377680a027b43841f5c96858e4e28d9
Parents:
bf5adf058537f0a83a68bcae3705ae81c3b87e22
Message:
poll for status
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/links/ssiLink.cc

    rbf5adf rb9861d  
    18851885  && (strcmp(request, "read") == 0))
    18861886  {
     1887    if (s_isready(d->f_read)) return "ready";
     1888#ifdef HAVE_POLL
     1889    pollfd pfd;
     1890    loop
     1891    {
     1892      /* Don't block. Return socket status immediately. */
     1893      pfd.fd=d->fd_read;
     1894      pfd.events=POLLIN;
     1895      //Print("test fd %d\n",d->fd_read);
     1896    /* check with select: chars waiting: no -> not ready */
     1897      switch (si_poll(&pfd,1,0))
     1898      {
     1899        case 0: /* not ready */ return "not ready";
     1900        case -1: /*error*/      return "error";
     1901        case 1: /*ready ? */    break;
     1902      }
     1903#else
    18871904    fd_set  mask;
    18881905    struct timeval wt;
    1889     if (s_isready(d->f_read)) return "ready";
    18901906    if (FD_SETSIZE<=d->fd_read)
    18911907    {
     
    19101926        case 1: /*ready ? */    break;
    19111927      }
     1928#endif
    19121929    /* yes: read 1 char*/
    19131930    /* if \n, check again with select else ungetc(c), ready*/
     
    19401957int slStatusSsiL(lists L, int timeout)
    19411958{
     1959  PrintS("select 1\n");
    19421960// input: L: a list with links of type
    19431961//           ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
     
    19551973  int d_fd;
    19561974  int s;
    1957 #ifdef HAVE_POLL
     1975//#ifdef HAVE_POLL
     1976#if 0
    19581977  int nfd=L->nr+1;
    19591978  int wait_for=0;
     
    19611980  for(int i=L->nr; i>=0; i--)
    19621981  {
     1982    pfd[i].fd=-1;
    19631983    if (L->m[i].Typ()!=DEF_CMD)
    19641984    {
     
    19992019  if (timeout>0) timeout=timeout/1000000;
    20002020do_poll:
    2001   s=poll(pfd,nfd,timeout);
     2021  s=si_poll(pfd,nfd,timeout);
    20022022  if (s==-1)
    20032023  {
     
    20272047            return i+1;
    20282048          }
    2029           if (pfd[i].revents &POLLERR)
     2049          if (pfd[i].revents) // anything else
    20302050          {
    20312051            wait_for--;
    2032             pfd[i].events=0;
     2052            pfd[i].fd=-1;
     2053            pfd[i].events=0;
    20332054          }
    20342055        }
     
    20372058  }
    20382059  // none ready, wait again:
    2039   if ((timeout!=0)&&(wait_for>0)) goto do_poll;
    2040   return 0;
     2060  if ((timeout<0)&&(wait_for>0)) goto do_poll;
     2061  if (timeout==0) return 0;
     2062  return -1;
    20412063#else
    20422064  fd_set  mask, fdmask;
Note: See TracChangeset for help on using the changeset viewer.