Print this page
10098 task_alloc() in libfakekernel gets KM_NOSLEEP test wrong

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libfakekernel/common/taskq.c
          +++ new/usr/src/lib/libfakekernel/common/taskq.c
↓ open down ↓ 92 lines elided ↑ open up ↑
  93   93  static taskq_ent_t *
  94   94  task_alloc(taskq_t *tq, int tqflags)
  95   95  {
  96   96          taskq_ent_t *t;
  97   97          int rv;
  98   98  
  99   99  again:  if ((t = tq->tq_freelist) != NULL && tq->tq_nalloc >= tq->tq_minalloc) {
 100  100                  tq->tq_freelist = t->tqent_next;
 101  101          } else {
 102  102                  if (tq->tq_nalloc >= tq->tq_maxalloc) {
 103      -                        if (!(tqflags & KM_SLEEP))
      103 +                        if (tqflags & KM_NOSLEEP)
 104  104                                  return (NULL);
 105  105  
 106  106                          /*
 107  107                           * We don't want to exceed tq_maxalloc, but we can't
 108  108                           * wait for other tasks to complete (and thus free up
 109  109                           * task structures) without risking deadlock with
 110  110                           * the caller.  So, we just delay for one second
 111  111                           * to throttle the allocation rate. If we have tasks
 112  112                           * complete before one second timeout expires then
 113  113                           * taskq_ent_free will signal us and we will
↓ open down ↓ 293 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX