src/event/ngx_event_posted.c - nginx source code

Global variables defined

Functions defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #include <ngx_config.h>
  6. #include <ngx_core.h>
  7. #include <ngx_event.h>


  8. ngx_queue_t  ngx_posted_accept_events;
  9. ngx_queue_t  ngx_posted_next_events;
  10. ngx_queue_t  ngx_posted_events;


  11. void
  12. ngx_event_process_posted(ngx_cycle_t *cycle, ngx_queue_t *posted)
  13. {
  14.     ngx_queue_t  *q;
  15.     ngx_event_t  *ev;

  16.     while (!ngx_queue_empty(posted)) {

  17.         q = ngx_queue_head(posted);
  18.         ev = ngx_queue_data(q, ngx_event_t, queue);

  19.         ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
  20.                       "posted event %p", ev);

  21.         ngx_delete_posted_event(ev);

  22.         ev->handler(ev);
  23.     }
  24. }


  25. void
  26. ngx_event_move_posted_next(ngx_cycle_t *cycle)
  27. {
  28.     ngx_queue_t  *q;
  29.     ngx_event_t  *ev;

  30.     for (q = ngx_queue_head(&ngx_posted_next_events);
  31.          q != ngx_queue_sentinel(&ngx_posted_next_events);
  32.          q = ngx_queue_next(q))
  33.     {
  34.         ev = ngx_queue_data(q, ngx_event_t, queue);

  35.         ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
  36.                       "posted next event %p", ev);

  37.         ev->ready = 1;
  38.         ev->available = -1;
  39.     }

  40.     ngx_queue_add(&ngx_posted_events, &ngx_posted_next_events);
  41.     ngx_queue_init(&ngx_posted_next_events);
  42. }