Changeset 1556


Ignore:
Timestamp:
Apr 26, 2016, 5:15:04 PM (9 years ago)
Author:
Silvan Scherrer
Message:

cups: remove the EOF workaround, as done proper now, enable the select() hack, as needed in the admin interface

Location:
cups/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified cups/trunk/cgi-bin/var.c

    r1554 r1556  
    779779  while (fgets(line, sizeof(line), stdin))
    780780  {
    781 #ifdef __OS2__
    782     if (!strcmp(line, "\r\n") || !strcmp(line, "\n"))
    783 #else
    784781    if (!strcmp(line, "\r\n"))
    785 #endif
    786782    {
    787783     /*
     
    828824        ptr = line;
    829825
    830 #ifdef __OS2__
    831         while ((ch = getchar()) != EOF && ch != '\n')
    832 #else
    833826        while ((ch = getchar()) != EOF)
    834 #endif
    835827        {
    836828          *ptr++ = (char)ch;
     
    873865        end = line + sizeof(line) - 1;
    874866
    875 #ifdef __OS2__
    876         while ((ch = getchar()) != EOF && ch != '\n')
    877 #else
    878867        while ((ch = getchar()) != EOF)
    879 #endif
    880868        {
    881869          if (ptr < end)
  • TabularUnified cups/trunk/scheduler/client.c

    r1358 r1556  
    21102110  if (con->filename)
    21112111  {
     2112#ifdef __OS2__
     2113    fd = open(con->filename, O_RDONLY | O_BINARY);
     2114#else
    21122115    fd = open(con->filename, O_RDONLY);
     2116#endif
    21132117
    21142118    if (fd < 0)
  • TabularUnified cups/trunk/scheduler/select.c

    r1365 r1556  
    618618                  NULL);
    619619
    620 #if 0 // #ifdef __EMX__ // @todo I doubt this part is needed
    621   /* libc's select() is flaky - pause 0.5 second and retry */   
    622   if (nfds == -1) {
     620#ifdef __OS2__
     621  /* libc's select() is flaky - pause 0.5 second and retry
     622   * @todo see why this is really needed
     623   * my findings are, that it's only needed when gutenprint is installed
     624   * somehow a cupsdPipeCommand needs very long to fork() execv() and so
     625   * the socket isn't ready */
     626  if (nfds == -1)
     627  {
     628    cupsdLogMessage(CUPSD_LOG_WARN, "cupsdDoSelect: select() returned %d... pause and retry select()",
     629                  nfds);
    623630    usleep(500000);
    624     cupsdLogMessage(CUPSD_LOG_INFO, "cupsdDoSelect: select() returned %d... pause and retry select()",
     631    if (timeout >= 0 && timeout < 86400)
     632    {
     633      stimeout.tv_sec  = timeout;
     634      stimeout.tv_usec = 0;
     635      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     636                  &stimeout);
     637    }
     638    else
     639      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     640                  NULL);
     641  }
     642
     643  if (nfds == -1)
     644  {
     645
     646    cupsdLogMessage(CUPSD_LOG_WARN, "cupsdDoSelect: select() returned %d (2nd failure)... pause and setting socket to non-blocking mode",
    625647                  nfds);
    626   if (timeout >= 0 && timeout < 86400)
    627   {
    628     stimeout.tv_sec  = timeout;
    629     stimeout.tv_usec = 0;
    630     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     648    /* fcntl O_NONBLOCK doesn't always succeed on OS/2 - force the socket to be non-blocking */
     649    char dontblock =1;
     650    os2_ioctl(maxfd, FIONBIO, &dontblock,sizeof(dontblock));
     651
     652    usleep(500000);
     653    if (timeout >= 0 && timeout < 86400)
     654    {
     655      stimeout.tv_sec  = timeout;
     656      stimeout.tv_usec = 0;
     657      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    631658                  &stimeout);
    632   }
    633   else
    634     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     659    }
     660    else
     661      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    635662                  NULL);
    636                 }
    637 
    638   if (nfds == -1) {
    639 
    640 
    641   /* fcntl O_NONBLOCK doesn't always succeed on OS/2 - force the socket to be non-blocking */
    642   char dontblock =1;
    643   cupsdLogMessage(CUPSD_LOG_INFO, "cupsdDoSelect: select() returned %d (2nd failure)... setting socket to non-blocking mode",
     663  }
     664
     665  if (nfds == -1)
     666  {
     667    cupsdLogMessage(CUPSD_LOG_WARN, "cupsdDoSelect: select() returned %d (3rd failure)... pause and retry select()",
    644668                  nfds);
    645   os2_ioctl(maxfd, FIONBIO, &dontblock,sizeof(dontblock));
    646 
    647   usleep(500000);
    648   cupsdLogMessage(CUPSD_LOG_INFO, "cupsdDoSelect: select() returned %d (2nd failure)... pause and retry select()",
    649                   nfds);
    650   if (timeout >= 0 && timeout < 86400)
    651   {
    652     stimeout.tv_sec  = timeout;
    653     stimeout.tv_usec = 0;
    654     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     669    usleep(500000);
     670    if (timeout >= 0 && timeout < 86400)
     671    {
     672      stimeout.tv_sec  = timeout;
     673      stimeout.tv_usec = 0;
     674      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    655675                  &stimeout);
    656   }
    657   else
    658     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
     676    }
     677    else
     678      nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    659679                  NULL);
    660                 }
    661 
    662   if (nfds == -1) {
    663     usleep(500000);
    664     cupsdLogMessage(CUPSD_LOG_INFO, "cupsdDoSelect: select() returned %d (3rd failure)... pause and retry select()",
    665                   nfds);
    666   if (timeout >= 0 && timeout < 86400)
    667   {
    668     stimeout.tv_sec  = timeout;
    669     stimeout.tv_usec = 0;
    670     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    671                   &stimeout);
    672   }
    673   else
    674     nfds = select(maxfd, &cupsd_current_input, &cupsd_current_output, NULL,
    675                   NULL);
    676                 }
    677 
     680  }
    678681#endif
    679682
Note: See TracChangeset for help on using the changeset viewer.