~ubuntu-branches/ubuntu/oneiric/cups/oneiric

« back to all changes in this revision

Viewing changes to scheduler/select.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-04-09 16:19:16 UTC
  • mto: (25.1.2 lucid) (55.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100409161916-k0e6prz52ubf4vlg
Tags: upstream-1.4.3
ImportĀ upstreamĀ versionĀ 1.4.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * "$Id: select.c 8753 2009-07-14 23:07:52Z mike $"
 
2
 * "$Id: select.c 8950 2010-01-14 22:40:19Z mike $"
3
3
 *
4
4
 *   Select abstraction functions for the Common UNIX Printing System (CUPS).
5
5
 *
136
136
 * 
137
137
 *     4. kqueue() - O(n)
138
138
 *         b. cupsdStartSelect() creates kqueue file descriptor
139
 
 *            using kqyeue() function and allocates a global event
 
139
 *            using kqueue() function and allocates a global event
140
140
 *            buffer.
141
141
 *         c. cupsdAdd/RemoveSelect() uses EV_SET and kevent() to
142
142
 *            register the changes. The event user data field is a
144
144
 *         d. cupsdDoSelect() uses kevent() to poll for events and
145
145
 *            loops through the events, using the user data field to
146
146
 *            find the callback record.
147
 
 *         e. cupsdStopSelect() closes the kqyeye() file descriptor
 
147
 *         e. cupsdStopSelect() closes the kqueue() file descriptor
148
148
 *            and frees all of the memory used by the event buffer.
149
149
 * 
150
150
 *     5. /dev/poll - O(n log n) - NOT YET IMPLEMENTED
454
454
    if (fdptr->read_cb && event->filter == EVFILT_READ)
455
455
      (*(fdptr->read_cb))(fdptr->data);
456
456
 
457
 
    if (fdptr->write_cb && event->filter == EVFILT_WRITE)
 
457
    if (fdptr->use > 1 && fdptr->write_cb && event->filter == EVFILT_WRITE)
458
458
      (*(fdptr->write_cb))(fdptr->data);
459
459
 
460
460
    release_fd(fdptr);
499
499
        if (fdptr->read_cb && (event->events & (EPOLLIN | EPOLLERR | EPOLLHUP)))
500
500
          (*(fdptr->read_cb))(fdptr->data);
501
501
 
502
 
        if (fdptr->write_cb && (event->events & (EPOLLOUT | EPOLLERR | EPOLLHUP)))
 
502
        if (fdptr->use > 1 && fdptr->write_cb &&
 
503
            (event->events & (EPOLLOUT | EPOLLERR | EPOLLHUP)))
503
504
          (*(fdptr->write_cb))(fdptr->data);
504
505
 
505
506
        release_fd(fdptr);
590
591
      if (fdptr->read_cb && (pfd->revents & (POLLIN | POLLERR | POLLHUP)))
591
592
        (*(fdptr->read_cb))(fdptr->data);
592
593
 
593
 
      if (fdptr->write_cb && (pfd->revents & (POLLOUT | POLLERR | POLLHUP)))
 
594
      if (fdptr->use > 1 && fdptr->write_cb &&
 
595
          (pfd->revents & (POLLOUT | POLLERR | POLLHUP)))
594
596
        (*(fdptr->write_cb))(fdptr->data);
595
597
 
596
598
      release_fd(fdptr);
645
647
      if (fdptr->read_cb && FD_ISSET(fdptr->fd, &cupsd_current_input))
646
648
        (*(fdptr->read_cb))(fdptr->data);
647
649
 
648
 
      if (fdptr->write_cb && FD_ISSET(fdptr->fd, &cupsd_current_output))
 
650
      if (fdptr->use > 1 && fdptr->write_cb &&
 
651
          FD_ISSET(fdptr->fd, &cupsd_current_output))
649
652
        (*(fdptr->write_cb))(fdptr->data);
650
653
 
651
654
      release_fd(fdptr);
942
945
 
943
946
 
944
947
/*
945
 
 * End of "$Id: select.c 8753 2009-07-14 23:07:52Z mike $".
 
948
 * End of "$Id: select.c 8950 2010-01-14 22:40:19Z mike $".
946
949
 */