mirror of
https://github.com/nginx/nginx.git
synced 2024-12-27 17:31:35 -06:00
nginx-0.0.1-2003-12-05-20:07:27 import
This commit is contained in:
parent
faca119aa5
commit
62260f2a15
@ -15,11 +15,6 @@ static int ngx_open_listening_sockets(ngx_cycle_t *cycle, ngx_log_t *log);
|
||||
static void ngx_clean_old_cycles(ngx_event_t *ev);
|
||||
|
||||
|
||||
#if (NGX_DEBUG) && (__FreeBSD__)
|
||||
extern char *malloc_options;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int daemon;
|
||||
} ngx_core_conf_t;
|
||||
@ -81,13 +76,8 @@ int main(int argc, char *const *argv)
|
||||
ngx_core_conf_t *ccf;
|
||||
#endif
|
||||
|
||||
#if (NGX_DEBUG) && (__FreeBSD__)
|
||||
#if __FreeBSD_version >= 500014
|
||||
_malloc_options
|
||||
#else
|
||||
malloc_options
|
||||
#endif
|
||||
= "J";
|
||||
#if __FreeBSD__
|
||||
ngx_debug_init();
|
||||
#endif
|
||||
|
||||
/* TODO */ ngx_max_sockets = -1;
|
||||
@ -134,7 +124,9 @@ int main(int argc, char *const *argv)
|
||||
/* life cycle */
|
||||
|
||||
for ( ;; ) {
|
||||
#if 0
|
||||
/* STUB */ cycle->log->log_level = NGX_LOG_DEBUG|NGX_LOG_DEBUG_HTTP;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
@ -255,13 +247,11 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
|
||||
ngx_listening_t *ls, *nls;
|
||||
|
||||
|
||||
pool = ngx_create_pool(16 * 1024, log);
|
||||
if (pool == NULL) {
|
||||
if (!(pool = ngx_create_pool(16 * 1024, log))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t));
|
||||
if (cycle == NULL) {
|
||||
if (!(cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)))) {
|
||||
ngx_destroy_pool(pool);
|
||||
return NULL;
|
||||
}
|
||||
@ -271,8 +261,7 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
|
||||
|
||||
|
||||
n = old_cycle ? old_cycle->pathes.nelts : 10;
|
||||
cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));
|
||||
if (cycle->pathes.elts == NULL) {
|
||||
if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) {
|
||||
ngx_destroy_pool(pool);
|
||||
return NULL;
|
||||
}
|
||||
@ -294,8 +283,7 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
|
||||
cycle->open_files.pool = pool;
|
||||
|
||||
|
||||
cycle->log = ngx_log_create_errlog(cycle, NULL);
|
||||
if (cycle->log == NULL) {
|
||||
if (!(cycle->log = ngx_log_create_errlog(cycle, NULL))) {
|
||||
ngx_destroy_pool(pool);
|
||||
return NULL;
|
||||
}
|
||||
@ -320,8 +308,7 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
|
||||
}
|
||||
|
||||
|
||||
ccf = ngx_pcalloc(pool, sizeof(ngx_core_conf_t));
|
||||
if (ccf == NULL) {
|
||||
if (!(ccf = ngx_pcalloc(pool, sizeof(ngx_core_conf_t)))) {
|
||||
ngx_destroy_pool(pool);
|
||||
return NULL;
|
||||
}
|
||||
@ -386,7 +373,9 @@ ngx_log_debug(log, "OPEN: %d:%s" _ file[i].fd _ file[i].name.data);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
|
||||
#endif
|
||||
|
||||
if (!failed) {
|
||||
if (old_cycle) {
|
||||
|
@ -22,7 +22,7 @@ static ngx_str_t errlog_name = ngx_string("errlog");
|
||||
static ngx_command_t ngx_errlog_commands[] = {
|
||||
|
||||
{ngx_string("error_log"),
|
||||
NGX_MAIN_CONF|NGX_CONF_TAKE1,
|
||||
NGX_MAIN_CONF|NGX_CONF_TAKE12,
|
||||
ngx_set_error_log,
|
||||
0,
|
||||
0,
|
||||
@ -233,12 +233,14 @@ ngx_log_t *ngx_log_init_errlog()
|
||||
ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE);
|
||||
|
||||
if (ngx_stderr.fd == NGX_INVALID_FILE) {
|
||||
/* TODO: where we can log error ? */
|
||||
/* TODO: where can we log error ? */
|
||||
return NULL;
|
||||
|
||||
} else if (ngx_stderr.fd == NULL) {
|
||||
|
||||
/* there are no associated standard handles */
|
||||
/* TODO: where we can log possible errors ? */
|
||||
|
||||
/* TODO: where can we can log possible errors ? */
|
||||
|
||||
ngx_stderr.fd = NGX_INVALID_FILE;
|
||||
}
|
||||
@ -251,7 +253,10 @@ ngx_log_t *ngx_log_init_errlog()
|
||||
|
||||
ngx_log.file = &ngx_stderr;
|
||||
ngx_log.log_level = NGX_LOG_INFO;
|
||||
|
||||
#if 0
|
||||
/* STUB */ ngx_log.log_level = NGX_LOG_DEBUG;
|
||||
#endif
|
||||
|
||||
return &ngx_log;
|
||||
}
|
||||
@ -264,7 +269,9 @@ ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name)
|
||||
ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL);
|
||||
ngx_test_null(log->file, ngx_conf_open_file(cycle, name), NULL);
|
||||
|
||||
#if 0
|
||||
/* STUB */ log->log_level = NGX_LOG_DEBUG;
|
||||
#endif
|
||||
|
||||
return log;
|
||||
}
|
||||
@ -272,6 +279,7 @@ ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name)
|
||||
|
||||
static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_int_t i;
|
||||
ngx_str_t *value;
|
||||
|
||||
value = cf->args->elts;
|
||||
@ -283,51 +291,19 @@ static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
cf->cycle->log->file->name = value[1];
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
char *ngx_log_set_errlog(ngx_conf_t *cf, ngx_command_t *cmd, ngx_log_t *log)
|
||||
{
|
||||
int len;
|
||||
ngx_err_t err;
|
||||
ngx_str_t *value;
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
log->file->fd = ngx_open_file(value[1].data,
|
||||
NGX_FILE_RDWR,
|
||||
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
|
||||
|
||||
if (log->file->fd == NGX_INVALID_FILE) {
|
||||
err = ngx_errno;
|
||||
len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||
ngx_open_file_n " \"%s\" failed (%d: ",
|
||||
value[1].data, err);
|
||||
len += ngx_strerror_r(err, ngx_conf_errstr + len,
|
||||
sizeof(ngx_conf_errstr) - len - 1);
|
||||
ngx_conf_errstr[len++] = ')';
|
||||
ngx_conf_errstr[len++] = '\0';
|
||||
return ngx_conf_errstr;
|
||||
if (cf->args->nelts == 3) {
|
||||
for (i = 1; i <= /* STUB ??? */ NGX_LOG_DEBUG; i++) {
|
||||
if (ngx_strcmp(value[2].data, err_levels[i]) == 0) {
|
||||
cf->cycle->log->log_level = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > NGX_LOG_DEBUG) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid log level \"%s\"", value[2].data);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#if (WIN32)
|
||||
if (ngx_file_append_mode(log->file->fd) == NGX_ERROR) {
|
||||
err = ngx_errno;
|
||||
len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||
ngx_file_append_mode_n " \"%s\" failed (%d: ",
|
||||
value[1].data, err);
|
||||
len += ngx_strerror_r(err, ngx_conf_errstr + len,
|
||||
sizeof(ngx_conf_errstr) - len - 1);
|
||||
ngx_conf_errstr[len++] = ')';
|
||||
ngx_conf_errstr[len++] = '\0';
|
||||
return ngx_conf_errstr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,23 +15,25 @@
|
||||
#define ngx_rbt_copy_color(n1, n2) (n1->color = n2->color)
|
||||
|
||||
|
||||
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root, ngx_rbtree_t *node);
|
||||
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
|
||||
ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node);
|
||||
ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
|
||||
ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node);
|
||||
|
||||
ngx_rbtree_t sentinel;
|
||||
|
||||
|
||||
void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node)
|
||||
{
|
||||
ngx_rbtree_t *temp;
|
||||
|
||||
/* a binary tree insert */
|
||||
|
||||
if (*root == &sentinel) {
|
||||
node->parent = &sentinel;
|
||||
node->left = &sentinel;
|
||||
node->right = &sentinel;
|
||||
if (*root == sentinel) {
|
||||
node->parent = sentinel;
|
||||
node->left = sentinel;
|
||||
node->right = sentinel;
|
||||
ngx_rbt_black(node);
|
||||
*root = node;
|
||||
|
||||
@ -42,7 +44,7 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
|
||||
for ( ;; ) {
|
||||
if (node->key < temp->key) {
|
||||
if (temp->left == &sentinel) {
|
||||
if (temp->left == sentinel) {
|
||||
temp->left = node;
|
||||
break;
|
||||
}
|
||||
@ -51,7 +53,7 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (temp->right == &sentinel) {
|
||||
if (temp->right == sentinel) {
|
||||
temp->right = node;
|
||||
break;
|
||||
}
|
||||
@ -61,8 +63,8 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
}
|
||||
|
||||
node->parent = temp;
|
||||
node->left = &sentinel;
|
||||
node->right = &sentinel;
|
||||
node->left = sentinel;
|
||||
node->right = sentinel;
|
||||
|
||||
|
||||
/* re-balance tree */
|
||||
@ -83,12 +85,12 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
} else {
|
||||
if (node == node->parent->right) {
|
||||
node = node->parent;
|
||||
ngx_rbtree_left_rotate(root, node);
|
||||
ngx_rbtree_left_rotate(root, sentinel, node);
|
||||
}
|
||||
|
||||
ngx_rbt_black(node->parent);
|
||||
ngx_rbt_red(node->parent->parent);
|
||||
ngx_rbtree_right_rotate(root, node->parent->parent);
|
||||
ngx_rbtree_right_rotate(root, sentinel, node->parent->parent);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -103,12 +105,12 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
} else {
|
||||
if (node == node->parent->left) {
|
||||
node = node->parent;
|
||||
ngx_rbtree_right_rotate(root, node);
|
||||
ngx_rbtree_right_rotate(root, sentinel, node);
|
||||
}
|
||||
|
||||
ngx_rbt_black(node->parent);
|
||||
ngx_rbt_red(node->parent->parent);
|
||||
ngx_rbtree_left_rotate(root, node->parent->parent);
|
||||
ngx_rbtree_left_rotate(root, sentinel, node->parent->parent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,34 +120,35 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
}
|
||||
|
||||
|
||||
void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node)
|
||||
{
|
||||
ngx_rbtree_t *subst, *temp, *w;
|
||||
|
||||
/* a binary tree delete */
|
||||
|
||||
if (node->left == &sentinel || node->right == &sentinel) {
|
||||
if (node->left == sentinel || node->right == sentinel) {
|
||||
subst = node;
|
||||
|
||||
} else {
|
||||
|
||||
/* find a node successor */
|
||||
|
||||
if (node->right == &sentinel) {
|
||||
if (node->right == sentinel) {
|
||||
temp = node;
|
||||
subst = node->parent;
|
||||
|
||||
while (subst != &sentinel && temp == subst->right) {
|
||||
while (subst != sentinel && temp == subst->right) {
|
||||
temp = subst;
|
||||
subst = subst->parent;
|
||||
}
|
||||
|
||||
} else {
|
||||
subst = ngx_rbtree_min(node->right);
|
||||
subst = ngx_rbtree_min(node->right, sentinel);
|
||||
}
|
||||
}
|
||||
|
||||
if (subst->left != &sentinel) {
|
||||
if (subst->left != sentinel) {
|
||||
temp = subst->left;
|
||||
} else {
|
||||
temp = subst->right;
|
||||
@ -153,7 +156,7 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
|
||||
temp->parent = subst->parent;
|
||||
|
||||
if (subst->parent == &sentinel) {
|
||||
if (subst->parent == sentinel) {
|
||||
*root = temp;
|
||||
|
||||
} else if (subst == subst->parent->left) {
|
||||
@ -174,14 +177,14 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
|
||||
/* a delete fixup */
|
||||
|
||||
while (temp->parent != &sentinel && ngx_rbt_is_black(temp)) {
|
||||
while (temp->parent != sentinel && ngx_rbt_is_black(temp)) {
|
||||
if (temp == temp->parent->left) {
|
||||
w = temp->parent->right;
|
||||
|
||||
if (ngx_rbt_is_red(w)) {
|
||||
ngx_rbt_black(w);
|
||||
ngx_rbt_red(temp->parent);
|
||||
ngx_rbtree_left_rotate(root, temp->parent);
|
||||
ngx_rbtree_left_rotate(root, sentinel, temp->parent);
|
||||
w = temp->parent->right;
|
||||
}
|
||||
|
||||
@ -193,14 +196,14 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
if (ngx_rbt_is_black(w->right)) {
|
||||
ngx_rbt_black(w->left);
|
||||
ngx_rbt_red(w);
|
||||
ngx_rbtree_right_rotate(root, w);
|
||||
ngx_rbtree_right_rotate(root, sentinel, w);
|
||||
w = temp->parent->right;
|
||||
}
|
||||
|
||||
ngx_rbt_copy_color(w, temp->parent);
|
||||
ngx_rbt_black(temp->parent);
|
||||
ngx_rbt_black(w->right);
|
||||
ngx_rbtree_left_rotate(root, temp->parent);
|
||||
ngx_rbtree_left_rotate(root, sentinel, temp->parent);
|
||||
temp = *root;
|
||||
}
|
||||
|
||||
@ -210,7 +213,7 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
if (ngx_rbt_is_red(w)) {
|
||||
ngx_rbt_black(w);
|
||||
ngx_rbt_red(temp->parent);
|
||||
ngx_rbtree_right_rotate(root, temp->parent);
|
||||
ngx_rbtree_right_rotate(root, sentinel, temp->parent);
|
||||
w = temp->parent->left;
|
||||
}
|
||||
|
||||
@ -222,14 +225,14 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
if (ngx_rbt_is_black(w->left)) {
|
||||
ngx_rbt_black(w->right);
|
||||
ngx_rbt_red(w);
|
||||
ngx_rbtree_left_rotate(root, w);
|
||||
ngx_rbtree_left_rotate(root, sentinel, w);
|
||||
w = temp->parent->left;
|
||||
}
|
||||
|
||||
ngx_rbt_copy_color(w, temp->parent);
|
||||
ngx_rbt_black(temp->parent);
|
||||
ngx_rbt_black(w->left);
|
||||
ngx_rbtree_right_rotate(root, temp->parent);
|
||||
ngx_rbtree_right_rotate(root, sentinel, temp->parent);
|
||||
temp = *root;
|
||||
}
|
||||
}
|
||||
@ -239,20 +242,22 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
}
|
||||
|
||||
|
||||
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
|
||||
ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node)
|
||||
{
|
||||
ngx_rbtree_t *temp;
|
||||
|
||||
temp = node->right;
|
||||
node->right = temp->left;
|
||||
|
||||
if (temp->left != &sentinel) {
|
||||
if (temp->left != sentinel) {
|
||||
temp->left->parent = node;
|
||||
}
|
||||
|
||||
temp->parent = node->parent;
|
||||
|
||||
if (node->parent == &sentinel) {
|
||||
if (node->parent == sentinel) {
|
||||
*root = temp;
|
||||
|
||||
} else if (node == node->parent->left) {
|
||||
@ -267,20 +272,22 @@ ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
}
|
||||
|
||||
|
||||
ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root, ngx_rbtree_t *node)
|
||||
ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
|
||||
ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node)
|
||||
{
|
||||
ngx_rbtree_t *temp;
|
||||
|
||||
temp = node->left;
|
||||
node->left = temp->right;
|
||||
|
||||
if (temp->right != &sentinel) {
|
||||
if (temp->right != sentinel) {
|
||||
temp->right->parent = node;
|
||||
}
|
||||
|
||||
temp->parent = node->parent;
|
||||
|
||||
if (node->parent == &sentinel) {
|
||||
if (node->parent == sentinel) {
|
||||
*root = temp;
|
||||
|
||||
} else if (node == node->parent->right) {
|
||||
|
@ -16,16 +16,17 @@ struct ngx_rbtree_s {
|
||||
char color;
|
||||
};
|
||||
|
||||
extern ngx_rbtree_t sentinel;
|
||||
|
||||
void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node);
|
||||
void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
|
||||
ngx_rbtree_t *node);
|
||||
|
||||
|
||||
void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *node);
|
||||
void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *node);
|
||||
|
||||
|
||||
ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *root)
|
||||
ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *root,
|
||||
ngx_rbtree_t *sentinel)
|
||||
{
|
||||
while (root->left != &sentinel) {
|
||||
while (root->left != sentinel) {
|
||||
root = root->left;
|
||||
}
|
||||
|
||||
|
@ -5,18 +5,19 @@
|
||||
|
||||
time_t ngx_cached_time;
|
||||
ngx_epoch_msec_t ngx_elapsed_msec;
|
||||
ngx_epoch_msec_t ngx_old_elapsed_msec;
|
||||
ngx_epoch_msec_t ngx_start_msec;
|
||||
|
||||
ngx_tm_t ngx_cached_gmtime;
|
||||
|
||||
static char cached_err_log_time[] = "1970/09/28 12:00:00";
|
||||
ngx_str_t ngx_cached_err_log_time;
|
||||
static char cached_err_log_time[] = "1970/09/28 12:00:00";
|
||||
ngx_str_t ngx_cached_err_log_time;
|
||||
|
||||
static char cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT";
|
||||
ngx_str_t ngx_cached_http_time;
|
||||
static char cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT";
|
||||
ngx_str_t ngx_cached_http_time;
|
||||
|
||||
static char cached_http_log_time[] = "28/Sep/1970:12:00:00";
|
||||
ngx_str_t ngx_cached_http_log_time;
|
||||
static char cached_http_log_time[] = "28/Sep/1970:12:00:00";
|
||||
ngx_str_t ngx_cached_http_log_time;
|
||||
|
||||
|
||||
static char *week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fir", "Sat" };
|
||||
@ -40,6 +41,7 @@ void ngx_time_init()
|
||||
ngx_gettimeofday(&tv);
|
||||
ngx_cached_time = tv.tv_sec;
|
||||
ngx_start_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
ngx_old_elapsed_msec = 0;
|
||||
ngx_elapsed_msec = 0;
|
||||
|
||||
ngx_time_update();
|
||||
|
@ -16,6 +16,7 @@ void ngx_gmtime(time_t t, ngx_tm_t *tp);
|
||||
|
||||
extern time_t ngx_cached_time;
|
||||
extern ngx_epoch_msec_t ngx_elapsed_msec;
|
||||
extern ngx_epoch_msec_t ngx_old_elapsed_msec;
|
||||
extern ngx_epoch_msec_t ngx_start_msec;
|
||||
|
||||
extern ngx_str_t ngx_cached_err_log_time;
|
||||
|
@ -354,6 +354,7 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
|
||||
struct timespec ts, *tp;
|
||||
|
||||
timer = ngx_event_find_timer();
|
||||
ngx_old_elapsed_msec = ngx_elapsed_msec;
|
||||
|
||||
if (timer) {
|
||||
ts.tv_sec = timer / 1000;
|
||||
@ -399,19 +400,6 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
|
||||
if (timer) {
|
||||
delta = ngx_elapsed_msec - delta;
|
||||
|
||||
#if 0
|
||||
delta = tv.tv_sec * 1000 + tv.tv_usec / 1000 - delta;
|
||||
|
||||
/*
|
||||
* The expired timers must be handled before a processing of the events
|
||||
* because the new timers can be added during a processing
|
||||
*/
|
||||
|
||||
ngx_event_expire_timers((ngx_msec_t) delta);
|
||||
|
||||
ngx_event_set_timer_delta((ngx_msec_t) delta);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
if (events == 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
@ -519,12 +507,6 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
|
||||
ngx_event_expire_timers((ngx_msec_t) delta);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (timer) {
|
||||
ngx_event_expire_timers((ngx_msec_t) delta);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ typedef struct {
|
||||
|
||||
struct ngx_event_s {
|
||||
void *data;
|
||||
/* TODO rename to handler, move flags to struct start */
|
||||
/* TODO rename to handler */
|
||||
void (*event_handler)(ngx_event_t *ev);
|
||||
|
||||
u_int index;
|
||||
@ -31,17 +31,14 @@ struct ngx_event_s {
|
||||
ngx_event_t *prev;
|
||||
ngx_event_t *next;
|
||||
|
||||
#if 0
|
||||
ngx_event_t *timer_prev;
|
||||
ngx_event_t *timer_next;
|
||||
|
||||
ngx_msec_t timer_delta;
|
||||
#endif
|
||||
|
||||
ngx_log_t *log;
|
||||
|
||||
/*
|
||||
* ngx_rbtree_t rbtree;
|
||||
* The inline of "ngx_rbtree_t rbtree;".
|
||||
*
|
||||
* It allows to pack rbtree_color and variuos event bit flags into
|
||||
* the single int. We also use "unsigned char" and then "usigned short"
|
||||
* because otherwise MSVC 6.0 uses an additional int for bit flags.
|
||||
*/
|
||||
|
||||
ngx_int_t rbtree_key;
|
||||
|
@ -5,14 +5,15 @@
|
||||
|
||||
|
||||
ngx_rbtree_t *ngx_event_timer_rbtree;
|
||||
ngx_rbtree_t ngx_event_timer_sentinel;
|
||||
|
||||
|
||||
int ngx_event_timer_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_event_timer_rbtree = &sentinel;
|
||||
sentinel.left = &sentinel;
|
||||
sentinel.right = &sentinel;
|
||||
sentinel.parent = &sentinel;
|
||||
ngx_event_timer_rbtree = &ngx_event_timer_sentinel;
|
||||
ngx_event_timer_sentinel.left = &ngx_event_timer_sentinel;
|
||||
ngx_event_timer_sentinel.right = &ngx_event_timer_sentinel;
|
||||
ngx_event_timer_sentinel.parent = &ngx_event_timer_sentinel;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
@ -27,9 +28,9 @@ ngx_msec_t ngx_event_find_timer(void)
|
||||
{
|
||||
ngx_rbtree_t *node;
|
||||
|
||||
node = ngx_rbtree_min(ngx_event_timer_rbtree);
|
||||
node = ngx_rbtree_min(ngx_event_timer_rbtree, &ngx_event_timer_sentinel);
|
||||
|
||||
if (node == &sentinel) {
|
||||
if (node == &ngx_event_timer_sentinel) {
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
@ -45,14 +46,15 @@ void ngx_event_expire_timers(ngx_msec_t timer)
|
||||
ngx_rbtree_t *node;
|
||||
|
||||
for ( ;; ) {
|
||||
node = ngx_rbtree_min(ngx_event_timer_rbtree);
|
||||
node = ngx_rbtree_min(ngx_event_timer_rbtree,
|
||||
&ngx_event_timer_sentinel);
|
||||
|
||||
if (node == &sentinel) {
|
||||
if (node == &ngx_event_timer_sentinel) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ngx_msec_t) node->key <= (ngx_msec_t)
|
||||
(ngx_elapsed_msec + timer) / NGX_TIMER_RESOLUTION)
|
||||
(ngx_old_elapsed_msec + timer) / NGX_TIMER_RESOLUTION)
|
||||
{
|
||||
ev = (ngx_event_t *)
|
||||
((char *) node - offsetof(ngx_event_t, rbtree_key));
|
||||
|
@ -35,11 +35,13 @@ void ngx_event_expire_timers(ngx_msec_t timer);
|
||||
|
||||
|
||||
extern ngx_rbtree_t *ngx_event_timer_rbtree;
|
||||
extern ngx_rbtree_t ngx_event_timer_sentinel;
|
||||
|
||||
|
||||
|
||||
ngx_inline static void ngx_event_del_timer(ngx_event_t *ev)
|
||||
{
|
||||
ngx_rbtree_delete(&ngx_event_timer_rbtree,
|
||||
ngx_rbtree_delete(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel,
|
||||
(ngx_rbtree_t *) &ev->rbtree_key);
|
||||
|
||||
ev->timer_set = 0;
|
||||
@ -55,7 +57,7 @@ ngx_inline static void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
|
||||
ev->rbtree_key = (ngx_int_t)
|
||||
(ngx_elapsed_msec + timer) / NGX_TIMER_RESOLUTION;
|
||||
|
||||
ngx_rbtree_insert(&ngx_event_timer_rbtree,
|
||||
ngx_rbtree_insert(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel,
|
||||
(ngx_rbtree_t *) &ev->rbtree_key);
|
||||
|
||||
ev->timer_set = 1;
|
||||
|
@ -514,13 +514,7 @@ ngx_log_debug(r->connection->log, "trans: %s: %d" _
|
||||
}
|
||||
|
||||
if (clcf->handler) {
|
||||
/*
|
||||
* if the location already has content handler then skip
|
||||
* the translation phase
|
||||
*/
|
||||
|
||||
r->content_handler = clcf->handler;
|
||||
r->phase++;
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
|
@ -79,5 +79,7 @@
|
||||
#define HAVE_LITTLE_ENDIAN 1
|
||||
|
||||
|
||||
extern char *malloc_options;
|
||||
|
||||
|
||||
#endif /* _NGX_FREEBSD_CONFIG_H_INCLUDED_ */
|
||||
|
@ -56,6 +56,20 @@ sysctl_t sysctls[] = {
|
||||
};
|
||||
|
||||
|
||||
void ngx_debug_init()
|
||||
{
|
||||
#if (NGX_DEBUG)
|
||||
|
||||
#if __FreeBSD_version >= 500014
|
||||
_malloc_options = "J";
|
||||
#else
|
||||
malloc_options = "J";
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ngx_os_init(ngx_log_t *log)
|
||||
{
|
||||
int i, version;
|
||||
|
@ -32,6 +32,7 @@ typedef struct {
|
||||
} ngx_os_io_t;
|
||||
|
||||
|
||||
void ngx_debug_init();
|
||||
int ngx_os_init(ngx_log_t *log);
|
||||
int ngx_daemon(ngx_log_t *log);
|
||||
int ngx_posix_init(ngx_log_t *log);
|
||||
|
Loading…
Reference in New Issue
Block a user