mirror of
https://github.com/nginx/nginx.git
synced 2024-12-19 21:53:31 -06:00
nginx-0.0.1-2003-01-23-21:47:54 import
This commit is contained in:
parent
6b7cfab3a6
commit
fcce8d529a
@ -9,6 +9,7 @@
|
||||
#include <ngx_log.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_devpoll_module.h>
|
||||
|
||||
#if (USE_DEVPOLL) && !(HAVE_DEVPOLL)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <ngx_log.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_kqueue_module.h>
|
||||
|
||||
#if (USE_KQUEUE) && !(HAVE_KQUEUE)
|
||||
@ -50,8 +51,14 @@ int ngx_kqueue_init(int max_connections, ngx_log_t *log)
|
||||
ngx_test_null(change_list, ngx_alloc(change_size, log), NGX_ERROR);
|
||||
ngx_test_null(event_list, ngx_alloc(event_size, log), NGX_ERROR);
|
||||
|
||||
if (ngx_event_init_timer(log) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
#if 0
|
||||
timer_queue.timer_prev = &timer_queue;
|
||||
timer_queue.timer_next = &timer_queue;
|
||||
#endif
|
||||
|
||||
#if !(USE_KQUEUE)
|
||||
ngx_event_actions.add = ngx_kqueue_add_event;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <ngx_time.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_poll_module.h>
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <ngx_time.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_select_module.h>
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <ngx_alloc.h>
|
||||
#include <ngx_array.h>
|
||||
|
||||
|
||||
#define NGX_INVALID_INDEX 0x80000000
|
||||
|
||||
typedef struct ngx_event_s ngx_event_t;
|
||||
@ -31,8 +32,8 @@ struct ngx_event_s {
|
||||
ngx_event_t *timer_prev;
|
||||
ngx_event_t *timer_next;
|
||||
|
||||
u_int timer_delta;
|
||||
u_int timer;
|
||||
ngx_msec_t timer_delta;
|
||||
ngx_msec_t timer;
|
||||
|
||||
ngx_log_t *log;
|
||||
|
||||
@ -150,7 +151,11 @@ NGX_CLOSE_EVENT kqueue: kqueue deletes events for file that closed
|
||||
#define ngx_process_events ngx_kqueue_process_events
|
||||
#define ngx_add_event ngx_kqueue_add_event
|
||||
#define ngx_del_event ngx_kqueue_del_event
|
||||
#if 0
|
||||
#define ngx_add_timer ngx_kqueue_add_timer
|
||||
#else
|
||||
#define ngx_add_timer ngx_event_add_timer
|
||||
#endif
|
||||
#define ngx_event_recv ngx_event_recv_core
|
||||
|
||||
#else
|
||||
@ -159,12 +164,19 @@ NGX_CLOSE_EVENT kqueue: kqueue deletes events for file that closed
|
||||
#define ngx_process_events ngx_event_actions.process
|
||||
#define ngx_add_event ngx_event_actions.add
|
||||
#define ngx_del_event ngx_event_actions.del
|
||||
#if 0
|
||||
#define ngx_add_timer ngx_event_actions.timer
|
||||
#else
|
||||
#define ngx_add_timer ngx_event_add_timer
|
||||
#endif
|
||||
#define ngx_event_recv ngx_event_recv_core
|
||||
|
||||
#endif
|
||||
|
||||
#define ngx_del_timer ngx_event_del_timer
|
||||
|
||||
|
||||
#if 0
|
||||
ngx_inline static void ngx_del_timer(ngx_event_t *ev)
|
||||
{
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
@ -186,7 +198,7 @@ ngx_inline static void ngx_del_timer(ngx_event_t *ev)
|
||||
ev->timer_prev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_types.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_event_close.h>
|
||||
|
||||
|
||||
|
@ -1,7 +1,43 @@
|
||||
|
||||
#include <ngx_config.h>
|
||||
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_log.h>
|
||||
#include <ngx_alloc.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
|
||||
#include <ngx_event_timer.h>
|
||||
|
||||
/* STUB */
|
||||
#define NGX_TIMER_HASH_SIZE 5
|
||||
|
||||
ngx_event_t *ngx_timer_queue;
|
||||
int ngx_timer_hash_size;
|
||||
|
||||
|
||||
void ngx_add_timer(ngx_event_t *ev, ngx_msec_t timer)
|
||||
int ngx_event_init_timer(ngx_log_t *log)
|
||||
{
|
||||
int i;
|
||||
|
||||
ngx_timer_hash_size = NGX_TIMER_HASH_SIZE;
|
||||
|
||||
ngx_test_null(ngx_timer_queue,
|
||||
ngx_alloc(ngx_timer_hash_size * sizeof(ngx_event_t), log),
|
||||
NGX_ERROR);
|
||||
|
||||
for (i = 0; i < ngx_timer_hash_size; i++) {
|
||||
ngx_timer_queue[i].timer_prev = &ngx_timer_queue[i];
|
||||
ngx_timer_queue[i].timer_next = &ngx_timer_queue[i];
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
|
||||
{
|
||||
int n;
|
||||
ngx_event_t *e;
|
||||
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
@ -16,8 +52,8 @@ void ngx_add_timer(ngx_event_t *ev, ngx_msec_t timer)
|
||||
|
||||
n = timer % ngx_timer_hash_size;
|
||||
|
||||
for (e = timer_queue[n].timer_next;
|
||||
e != &timer_queue[n] && timer > e->timer_delta;
|
||||
for (e = ngx_timer_queue[n].timer_next;
|
||||
e != &ngx_timer_queue[n] && timer > e->timer_delta;
|
||||
e = e->timer_next)
|
||||
{
|
||||
timer -= e->timer_delta;
|
||||
|
65
src/event/ngx_event_timer.h
Normal file
65
src/event/ngx_event_timer.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef _NGX_EVENT_TIMER_H_INCLUDED_
|
||||
#define _NGX_EVENT_TIMER_H_INCLUDED_
|
||||
|
||||
|
||||
#include <ngx_config.h>
|
||||
|
||||
#include <ngx_log.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
|
||||
|
||||
int ngx_event_init_timer(ngx_log_t *log);
|
||||
void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer);
|
||||
|
||||
extern ngx_event_t *ngx_timer_queue;
|
||||
extern int ngx_timer_hash_size;
|
||||
|
||||
|
||||
ngx_inline static int ngx_event_get_timer()
|
||||
{
|
||||
int i;
|
||||
ngx_msec_t timer;
|
||||
|
||||
timer = NGX_MAX_MSEC;
|
||||
|
||||
for (i = 0; i < ngx_timer_hash_size; i++) {
|
||||
if (ngx_timer_queue[i].timer_next != &ngx_timer_queue[i]) {
|
||||
if (timer > ngx_timer_queue[i].timer_next->timer_delta) {
|
||||
timer = ngx_timer_queue[i].timer_next->timer_delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timer == NGX_MAX_MSEC) {
|
||||
return 0;
|
||||
} else {
|
||||
return timer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngx_inline static void ngx_event_del_timer(ngx_event_t *ev)
|
||||
{
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
/* STUB - we can not cast (ngx_connection_t *) here */
|
||||
ngx_log_debug(ev->log, "del timer: %d" _ *(int *)(ev->data));
|
||||
#endif
|
||||
|
||||
if (ev->timer_prev) {
|
||||
ev->timer_prev->timer_next = ev->timer_next;
|
||||
}
|
||||
|
||||
if (ev->timer_next) {
|
||||
ev->timer_next->timer_delta += ev->timer_delta;
|
||||
ev->timer_next->timer_prev = ev->timer_prev;
|
||||
ev->timer_next = NULL;
|
||||
}
|
||||
|
||||
if (ev->timer_prev) {
|
||||
ev->timer_prev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif _NGX_EVENT_TIMER_H_INCLUDED_
|
@ -12,6 +12,8 @@
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_conf_file.h>
|
||||
|
||||
/* STUB */
|
||||
#include <ngx_event_timer.h>
|
||||
|
||||
#define NGX_HTTP_VERSION_10 1000
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <ngx_table.h>
|
||||
#include <ngx_hunk.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
#include <ngx_inet.h>
|
||||
#include <ngx_http.h>
|
||||
#include <ngx_http_config.h>
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <ngx_config.h>
|
||||
|
||||
typedef u_int ngx_msec_t;
|
||||
#define NGX_MAX_MSEC ~0
|
||||
|
||||
typedef struct tm ngx_tm_t;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
typedef unsigned int ngx_msec_t;
|
||||
#define NGX_MAX_MSEC ~0
|
||||
|
||||
|
||||
typedef SYSTEMTIME ngx_tm_t;
|
||||
typedef FILETIME ngx_mtime_t;
|
||||
|
Loading…
Reference in New Issue
Block a user