[BACK]Return to file.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sndiod

Diff for /src/usr.bin/sndiod/file.c between version 1.11 and 1.12

version 1.11, 2015/07/17 10:15:24 version 1.12, 2015/08/01 10:47:30
Line 269 
Line 269 
 #endif  #endif
 }  }
   
   void
   file_process(struct file *f, struct pollfd *pfd)
   {
           int revents;
   #ifdef DEBUG
           struct timespec ts0, ts1;
           long us;
   #endif
   
   #ifdef DEBUG
           if (log_level >= 3)
                   clock_gettime(CLOCK_MONOTONIC, &ts0);
   #endif
           revents = (f->state != FILE_ZOMB) ?
               f->ops->revents(f->arg, pfd) : 0;
           if ((revents & POLLHUP) && (f->state != FILE_ZOMB))
                   f->ops->hup(f->arg);
           if ((revents & POLLIN) && (f->state != FILE_ZOMB))
                   f->ops->in(f->arg);
           if ((revents & POLLOUT) && (f->state != FILE_ZOMB))
                   f->ops->out(f->arg);
   #ifdef DEBUG
           if (log_level >= 3) {
                   clock_gettime(CLOCK_MONOTONIC, &ts1);
                   us = 1000000L * (ts1.tv_sec - ts0.tv_sec);
                   us += (ts1.tv_nsec - ts0.tv_nsec) / 1000;
                   if (log_level >= 4 || us >= 5000) {
                           file_log(f);
                           log_puts(": processed in ");
                           log_putu(us);
                           log_puts("us\n");
                   }
           }
   #endif
   }
   
 int  int
 file_poll(void)  file_poll(void)
 {  {
Line 277 
Line 313 
         struct timespec ts;          struct timespec ts;
 #ifdef DEBUG  #ifdef DEBUG
         struct timespec sleepts;          struct timespec sleepts;
         struct timespec ts0, ts1;  
         long us;  
         int i;          int i;
 #endif  #endif
         long long delta_nsec;          long long delta_nsec;
         int nfds, revents, res, immed;          int nfds, res;
   
           log_flush();
   
         /*          /*
          * cleanup zombies           * cleanup zombies
          */           */
Line 304 
Line 340 
                 return 0;                  return 0;
         }          }
   
         log_flush();          /*
            * fill pollfd structures
            */
         nfds = 0;          nfds = 0;
         immed = 0;  
         for (f = file_list; f != NULL; f = f->next) {          for (f = file_list; f != NULL; f = f->next) {
                 f->nfds = f->ops->pollfd(f->arg, pfds + nfds);                  f->nfds = f->ops->pollfd(f->arg, pfds + nfds);
                 if (f->nfds == 0)                  if (f->nfds == 0)
                         continue;                          continue;
                 if (f->nfds < 0) {  
                         immed = 1;  
                         continue;  
                 }  
                 nfds += f->nfds;                  nfds += f->nfds;
         }          }
 #ifdef DEBUG  #ifdef DEBUG
Line 322 
Line 355 
                 log_puts("poll:");                  log_puts("poll:");
                 pfd = pfds;                  pfd = pfds;
                 for (f = file_list; f != NULL; f = f->next) {                  for (f = file_list; f != NULL; f = f->next) {
                         if (f->nfds <= 0)                          if (f->nfds == 0)
                                 continue;                                  continue;
                         log_puts(" ");                          log_puts(" ");
                         log_puts(f->ops->name);                          log_puts(f->ops->name);
Line 335 
Line 368 
                 }                  }
                 log_puts("\n");                  log_puts("\n");
         }          }
   #endif
   
           /*
            * process files that do not rely on poll
            */
           for (f = file_list; f != NULL; f = f->next) {
                   if (f->nfds > 0)
                           continue;
                   file_process(f, NULL);
           }
   
           /*
            * sleep
            */
   #ifdef DEBUG
         clock_gettime(CLOCK_MONOTONIC, &sleepts);          clock_gettime(CLOCK_MONOTONIC, &sleepts);
         file_utime += 1000000000LL * (sleepts.tv_sec - file_ts.tv_sec);          file_utime += 1000000000LL * (sleepts.tv_sec - file_ts.tv_sec);
         file_utime += sleepts.tv_nsec - file_ts.tv_nsec;          file_utime += sleepts.tv_nsec - file_ts.tv_nsec;
 #endif  #endif
         if (!immed) {          res = poll(pfds, nfds, TIMER_MSEC);
                 res = poll(pfds, nfds, TIMER_MSEC);          if (res < 0) {
                 if (res < 0 && errno != EINTR)                  if (errno != EINTR)
                         err(1, "poll");                          err(1, "poll");
         } else                  return 1;
                 res = 0;          }
   
           /*
            * run timeouts
            */
         clock_gettime(CLOCK_MONOTONIC, &ts);          clock_gettime(CLOCK_MONOTONIC, &ts);
 #ifdef DEBUG  #ifdef DEBUG
         file_wtime += 1000000000LL * (ts.tv_sec - sleepts.tv_sec);          file_wtime += 1000000000LL * (ts.tv_sec - sleepts.tv_sec);
Line 363 
Line 415 
                 if (log_level >= 2)                  if (log_level >= 2)
                         log_puts("ignored huge clock delta\n");                          log_puts("ignored huge clock delta\n");
         }          }
         if (!immed && res <= 0)  
                 return 1;          /*
            * process files that rely on poll
            */
         pfd = pfds;          pfd = pfds;
         for (f = file_list; f != NULL; f = f->next) {          for (f = file_list; f != NULL; f = f->next) {
                 if (f->nfds <= 0)                  if (f->nfds == 0)
                         continue;                          continue;
 #ifdef DEBUG                  file_process(f, pfd);
                 if (log_level >= 3)  
                         clock_gettime(CLOCK_MONOTONIC, &ts0);  
 #endif  
                 revents = (f->state != FILE_ZOMB) ?  
                     f->ops->revents(f->arg, pfd) : 0;  
                 if ((revents & POLLHUP) && (f->state != FILE_ZOMB))  
                         f->ops->hup(f->arg);  
                 if ((revents & POLLIN) && (f->state != FILE_ZOMB))  
                         f->ops->in(f->arg);  
                 if ((revents & POLLOUT) && (f->state != FILE_ZOMB))  
                         f->ops->out(f->arg);  
 #ifdef DEBUG  
                 if (log_level >= 3) {  
                         clock_gettime(CLOCK_MONOTONIC, &ts1);  
                         us = 1000000L * (ts1.tv_sec - ts0.tv_sec);  
                         us += (ts1.tv_nsec - ts0.tv_nsec) / 1000;  
                         if (log_level >= 4 || us >= 5000) {  
                                 file_log(f);  
                                 log_puts(": processed in ");  
                                 log_putu(us);  
                                 log_puts("us\n");  
                         }  
                 }  
 #endif  
                 pfd += f->nfds;                  pfd += f->nfds;
         }          }
         return 1;          return 1;

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12