Changeset a00221d in git


Ignore:
Timestamp:
Sep 17, 2010, 4:18:56 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
db71a2daf9759c0893a178e8e78e2b4779930cbc
Parents:
7194edf653bb54e050d46f0f8090b86b6ac49d1c
Message:
int slStatusSsiL(lists L, int timeout)

git-svn-id: file:///usr/local/Singular/svn/trunk@13212 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ssiLink.cc

    r7194edf ra00221d  
    999999}
    10001000
     1001int slStatusSsiL(lists L, int timeout)
     1002{
     1003  si_link l;
     1004  ssiInfo *d;
     1005  fd_set  mask, fdmask;
     1006  FD_ZERO(&mask);
     1007  int max_fd=0; /* max fd in fd_set */
     1008  struct timeval wt;
     1009  int i;
     1010  for(i=L->nr-1; i>=0; i--)
     1011  {
     1012    if (L->m[i].Typ()!=LINK_CMD)
     1013    { WerrorS("all elements must be of type link"); return -2;}
     1014    l=(si_link)L->m[i].Data();
     1015    if(!SI_LINK_OPEN_P(l))
     1016    { WerrorS("all links must be open"); return -2;}
     1017    if ((strcmp(l->m->type,"ssi")!=0)
     1018    && (strcmp(l->mode,"fork")!=0) || (strcmp(l->mode,"tcp")!=NULL))
     1019    { WerrorS("all links must be of type ssi:fork or ssi:tcp"); return -2;}
     1020    d=(ssiInfo*)l->data;
     1021    FD_SET(d->fd_read, &mask);
     1022    if (d->fd_read> max_fd) max_fd=d->fd_read;
     1023  }
     1024  struct timeval *wt_ptr=&wt;
     1025  if (timeout== -1)
     1026  {
     1027    wt_ptr=NULL;
     1028  }
     1029  else
     1030  {
     1031    wt.tv_sec  = timeout / 1000000;
     1032    wt.tv_usec = timeout % 1000000;
     1033  }
     1034  /* check with select: chars waiting: no -> not ready */
     1035  int s= select(max_fd, &mask, NULL, NULL, wt_ptr);
     1036  if (s==-1) return -2; /*error*/
     1037  if (s==0)
     1038  {
     1039    return -1; /*poll: not ready */
     1040  }
     1041  else /* s>0, at least one ready */
     1042  {
     1043    int j=0;
     1044    while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
     1045    for(i=L->nr-1; i>=0; i--)
     1046    {
     1047      l=(si_link)L->m[i].Data();
     1048      d=(ssiInfo*)l->data;
     1049      if(j==d->fd_read) break;
     1050    }
     1051    loop
     1052    {
     1053      /* yes: read 1 char*/
     1054      /* if \n, check again with select else ungetc(c), ready*/
     1055      /* setting: d: current ssiInfo, j current fd, i current entry in L*/
     1056      int c=fgetc(d->f_read);
     1057      //Print("try c=%d\n",c);
     1058      if (c== -1) return 0;
     1059      else if (isdigit(c))
     1060      { ungetc(c,d->f_read); return i+1; }
     1061      else if (c>' ')
     1062      {
     1063        Werror("unknown char in ssiLink(%d)",c);
     1064        return -2;
     1065      }
     1066      /* else: next char */
     1067    }
     1068  }
     1069}
     1070
    10011071int ssiBatch(const char *host, const char * port)
    10021072/* return 0 on success, >0 else*/
Note: See TracChangeset for help on using the changeset viewer.