mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 15:39:01 +08:00
nginx-0.0.1-2003-11-21-09:30:49 import
This commit is contained in:
parent
1ef225254e
commit
d9d0ca1268
35
auto/configure
vendored
35
auto/configure
vendored
@ -1,8 +1,28 @@
|
||||
|
||||
CC=cc
|
||||
CPP='cc -E'
|
||||
CC_STRONG="$CC -Wall -Werror"
|
||||
CPP="$CC -E"
|
||||
|
||||
NGX_AUTO_CONFIG_H=ngx_auto_config.h
|
||||
|
||||
echo > $NGX_AUTO_CONFIG_H
|
||||
|
||||
|
||||
CC_WARN=$CC_STRONG
|
||||
|
||||
NGX_FMT_NAME=OFF_FMT
|
||||
NGX_TYPE="off_t"; . auto/types/sizeof
|
||||
NGX_FORMATS="%ld %lld %qd"; . auto/fmt/fmt
|
||||
|
||||
NGX_FMT_NAME=TIME_FMT
|
||||
NGX_TYPE="time_t"; . auto/types/sizeof
|
||||
NGX_FORMATS="%d %ld %lld %qd"; . auto/fmt/fmt
|
||||
|
||||
|
||||
CC_WARN=$CC
|
||||
|
||||
exit
|
||||
|
||||
echo > ngx_auto_config.h
|
||||
|
||||
NGX_TYPE="long"; . auto/types/sizeof; NGX_MAX_LONG=$NGX_MAX_SIZE
|
||||
NGX_FORMATS="l"; . auto/fmt/fmt
|
||||
@ -11,6 +31,15 @@ NGX_FORMATS="l"; . auto/fmt/fmt
|
||||
NGX_TYPE="long long"; . auto/types/sizeof; NGX_MAX_LONG_LONG=$NGX_MAX_SIZE
|
||||
NGX_FORMATS="ll q"; . auto/fmt/fmt
|
||||
|
||||
|
||||
CC_WARN=$CC_STRONG
|
||||
|
||||
NGX_TYPE="off_t"; . auto/types/sizeof
|
||||
NGX_FORMATS="l ll q"; . auto/fmt/fmt
|
||||
|
||||
|
||||
CC_WARN=$CC
|
||||
|
||||
#NGX_TYPE="__int64_t"; . auto/types/typedef; NGX_TIME_T_FMT=$NGX_FMT
|
||||
|
||||
#NGX_TYPE="time_t"; . auto/types/typedef; NGX_TIME_T_FMT=$NGX_FMT
|
||||
@ -18,8 +47,6 @@ NGX_FORMATS="ll q"; . auto/fmt/fmt
|
||||
|
||||
#exit
|
||||
|
||||
. auto/types/time_t
|
||||
|
||||
. auto/types/uint64_t
|
||||
. auto/types/uintptr_t
|
||||
|
||||
|
29
auto/fmt/fmt
29
auto/fmt/fmt
@ -1,21 +1,24 @@
|
||||
|
||||
echo "Checking for printf() $NGX_TYPE format"
|
||||
echo "Checking for $NGX_TYPE printf() format"
|
||||
|
||||
NGX_FMT=NO
|
||||
|
||||
for FMT in $NGX_FORMATS
|
||||
do
|
||||
echo "int main() {" > autotest.c
|
||||
echo "printf(\"%${FMT}u\", (unsigned $NGX_TYPE) -1);" >> autotest.c
|
||||
echo "#include <unistd.h>" > autotest.c
|
||||
echo "#include <stdio.h>" >> autotest.c
|
||||
echo "#include <sys/types.h>" >> autotest.c
|
||||
echo "int main() {" >> autotest.c
|
||||
echo "printf(\"${FMT}\", ($NGX_TYPE) $NGX_MAX_SIZE);" >> autotest.c
|
||||
echo "return 0; }" >> autotest.c
|
||||
|
||||
eval "${CC} -o autotest autotest.c > /dev/null 2>&1"
|
||||
eval "${CC_WARN} -o autotest autotest.c > /dev/null 2>&1"
|
||||
|
||||
if [ -x ./autotest -a "`./autotest`" = $NGX_MAX_SIZE ]; then
|
||||
echo " + \"%${FMT}\" used"
|
||||
NGX_FMT=$FMT
|
||||
else
|
||||
echo " + \"%${FMT}\" is not appropriate"
|
||||
if [ -x ./autotest ]; then
|
||||
if [ "`./autotest`" = $NGX_MAX_SIZE ]; then
|
||||
echo " + \"${FMT}\" used"
|
||||
NGX_FMT=$FMT
|
||||
fi
|
||||
fi
|
||||
|
||||
rm autotest*
|
||||
@ -23,6 +26,8 @@ do
|
||||
if [ $NGX_FMT != NO ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
echo " + \"${FMT}\" is not appropriate"
|
||||
done
|
||||
|
||||
|
||||
@ -30,3 +35,9 @@ if [ $NGX_FMT = NO ]; then
|
||||
echo "printf() $NGX_TYPE format not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "#ifndef $NGX_FMT_NAME" >> $NGX_AUTO_CONFIG_H
|
||||
echo "#define $NGX_FMT_NAME \"$NGX_FMT\"" >> $NGX_AUTO_CONFIG_H
|
||||
echo "#endif" >> $NGX_AUTO_CONFIG_H
|
||||
echo >> $NGX_AUTO_CONFIG_H
|
||||
|
@ -3,7 +3,8 @@ echo "Checking for $NGX_TYPE size"
|
||||
|
||||
BYTES=
|
||||
|
||||
echo "int main() {" > autotest.c
|
||||
echo "#include <sys/types.h>" > autotest.c
|
||||
echo "int main() {" >> autotest.c
|
||||
echo "printf(\"%d\", sizeof($NGX_TYPE));" >> autotest.c
|
||||
echo "return 0; }" >> autotest.c
|
||||
|
||||
@ -18,11 +19,11 @@ rm autotest*
|
||||
|
||||
case $BYTES in
|
||||
4)
|
||||
NGX_MAX_SIZE=4294967295
|
||||
NGX_MAX_SIZE=2147483647
|
||||
;;
|
||||
|
||||
8)
|
||||
NGX_MAX_SIZE=18446744073709551615
|
||||
NGX_MAX_SIZE=9223372036854775807
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -230,7 +230,7 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
|
||||
|
||||
cycle = ngx_init_cycle(cycle, cycle->log);
|
||||
if (cycle == NULL) {
|
||||
cycle = (ngx_cycle_t*) ngx_cycle;
|
||||
cycle = (ngx_cycle_t *) ngx_cycle;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,9 @@
|
||||
|
||||
void *ngx_alloc(size_t size, ngx_log_t *log)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
p = malloc(size);
|
||||
if (p == NULL) {
|
||||
if (!(p = malloc(size))) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
"malloc() %d bytes failed", size);
|
||||
}
|
||||
@ -23,7 +22,7 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
|
||||
|
||||
void *ngx_calloc(size_t size, ngx_log_t *log)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
p = ngx_alloc(size, log);
|
||||
if (p) {
|
||||
@ -36,9 +35,11 @@ void *ngx_calloc(size_t size, ngx_log_t *log)
|
||||
|
||||
ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
|
||||
{
|
||||
ngx_pool_t *p;
|
||||
ngx_pool_t *p;
|
||||
|
||||
ngx_test_null(p, ngx_alloc(size, log), NULL);
|
||||
if (!(p = ngx_alloc(size, log))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->last = (char *) p + sizeof(ngx_pool_t);
|
||||
p->end = (char *) p + size;
|
||||
@ -115,7 +116,10 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
||||
|
||||
/* alloc a new pool block */
|
||||
|
||||
ngx_test_null(n, ngx_create_pool(p->end - (char *) p, p->log), NULL);
|
||||
if (!(n = ngx_create_pool((size_t) (p->end - (char *) p), p->log))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->next = n;
|
||||
m = n->last;
|
||||
n->last += size;
|
||||
@ -143,11 +147,16 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
||||
}
|
||||
|
||||
if (large == NULL) {
|
||||
ngx_test_null(large, ngx_palloc(pool, sizeof(ngx_pool_large_t)), NULL);
|
||||
if (!(large = ngx_palloc(pool, sizeof(ngx_pool_large_t)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
large->next = NULL;
|
||||
}
|
||||
|
||||
ngx_test_null(p, ngx_alloc(size, pool->log), NULL);
|
||||
if (!(p = ngx_alloc(size, pool->log))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pool->large == NULL) {
|
||||
pool->large = large;
|
||||
|
@ -315,12 +315,12 @@ ngx_log_debug(cf->log, "TOKEN START");
|
||||
}
|
||||
|
||||
if (h->pos - start) {
|
||||
ngx_memcpy(h->start, start, h->pos - start);
|
||||
ngx_memcpy(h->start, start, (size_t) (h->pos - start));
|
||||
}
|
||||
|
||||
n = ngx_read_file(&cf->conf_file->file,
|
||||
h->start + (h->pos - start),
|
||||
h->end - (h->start + (h->pos - start)),
|
||||
(size_t) (h->end - (h->start + (h->pos - start))),
|
||||
cf->conf_file->file.offset);
|
||||
|
||||
if (n == NGX_ERROR) {
|
||||
@ -462,7 +462,8 @@ ngx_log_debug(cf->log, "%d:%d:%d:%d:%d '%c'" _
|
||||
if (found) {
|
||||
ngx_test_null(word, ngx_push_array(cf->args), NGX_ERROR);
|
||||
ngx_test_null(word->data,
|
||||
ngx_palloc(cf->pool, h->pos - start + 1),
|
||||
ngx_palloc(cf->pool,
|
||||
(size_t) (h->pos - start + 1)),
|
||||
NGX_ERROR);
|
||||
|
||||
for (dst = word->data, src = start, len = 0;
|
||||
|
@ -28,8 +28,8 @@ typedef struct {
|
||||
ngx_log_t *log;
|
||||
int backlog;
|
||||
|
||||
int pool_size;
|
||||
int post_accept_buffer_size; /* should be here because
|
||||
size_t pool_size;
|
||||
size_t post_accept_buffer_size; /* should be here because
|
||||
of the AcceptEx() preread */
|
||||
time_t post_accept_timeout; /* should be here because
|
||||
of the deferred accept */
|
||||
|
@ -105,7 +105,8 @@ ngx_log_debug(file->log, "temp fd: %d" _ file->fd);
|
||||
|
||||
void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
|
||||
{
|
||||
int i, name, pos, level;
|
||||
int i, name, pos;
|
||||
size_t level;
|
||||
|
||||
name = file->name.len;
|
||||
pos = path->name.len + 1;
|
||||
@ -192,7 +193,7 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
char *p = conf;
|
||||
|
||||
int i, n;
|
||||
int i, n, level;
|
||||
ngx_str_t *value;
|
||||
ngx_path_t *path, **pp;
|
||||
|
||||
@ -219,12 +220,12 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
path->len = 0;
|
||||
|
||||
for (i = 0, n = 2; n < cf->args->nelts; i++, n++) {
|
||||
path->level[i] = ngx_atoi(value[n].data, value[n].len);
|
||||
if (path->level[i] == NGX_ERROR || path->level[i] == 0) {
|
||||
level = ngx_atoi(value[n].data, value[n].len);
|
||||
if (level == NGX_ERROR || level == 0) {
|
||||
return "invalid value";
|
||||
}
|
||||
|
||||
path->len += path->level[i] + 1;
|
||||
path->len += path->level[i] + level + 1;
|
||||
}
|
||||
|
||||
while (i < 3) {
|
||||
|
@ -27,8 +27,8 @@ struct ngx_file_s {
|
||||
|
||||
struct ngx_path_s {
|
||||
ngx_str_t name;
|
||||
int len;
|
||||
int level[3];
|
||||
u_int len;
|
||||
u_int level[3];
|
||||
ngx_gc_handler_pt gc_handler;
|
||||
};
|
||||
|
||||
|
@ -70,8 +70,9 @@ void stub_init(ngx_cycle_t *cycle)
|
||||
|
||||
static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
|
||||
{
|
||||
int rc, len;
|
||||
int rc;
|
||||
char *last;
|
||||
size_t len;
|
||||
ngx_err_t err;
|
||||
ngx_str_t fname, buf;
|
||||
ngx_dir_t dir;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <ngx_core.h>
|
||||
|
||||
|
||||
ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size)
|
||||
ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, size_t size)
|
||||
{
|
||||
ngx_hunk_t *h;
|
||||
|
||||
|
@ -124,7 +124,7 @@ typedef struct {
|
||||
(size_t) (h->file_last - h->file_pos))
|
||||
|
||||
|
||||
ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size);
|
||||
ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, size_t size);
|
||||
|
||||
#define ngx_alloc_hunk(pool) ngx_palloc(pool, sizeof(ngx_hunk_t))
|
||||
#define ngx_calloc_hunk(pool) ngx_pcalloc(pool, sizeof(ngx_hunk_t))
|
||||
|
@ -10,14 +10,13 @@
|
||||
ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx,
|
||||
ngx_hunk_t *hunk);
|
||||
static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
|
||||
int sendfile);
|
||||
u_int sendfile);
|
||||
|
||||
|
||||
int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
||||
{
|
||||
int rc, last;
|
||||
size_t hsize;
|
||||
ssize_t size;
|
||||
size_t size, hsize;
|
||||
ngx_chain_t *cl, *out, **last_out;
|
||||
|
||||
/*
|
||||
@ -191,13 +190,14 @@ ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx,
|
||||
|
||||
|
||||
static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
|
||||
int sendfile)
|
||||
u_int sendfile)
|
||||
{
|
||||
ssize_t n, size;
|
||||
size_t size;
|
||||
ssize_t n;
|
||||
|
||||
size = ngx_hunk_size(src);
|
||||
|
||||
if (size > (dst->end - dst->pos)) {
|
||||
if (size > (size_t) (dst->end - dst->pos)) {
|
||||
size = dst->end - dst->pos;
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
|
||||
}
|
||||
#endif
|
||||
|
||||
if (n != size) {
|
||||
if ((size_t) n != size) {
|
||||
ngx_log_error(NGX_LOG_ALERT, src->file->log, 0,
|
||||
ngx_read_file_n " reads only %d of %d from file",
|
||||
n, size);
|
||||
|
@ -5,8 +5,9 @@
|
||||
|
||||
int ngx_parse_size(ngx_str_t *line)
|
||||
{
|
||||
int len, scale, size;
|
||||
char last;
|
||||
int scale, size;
|
||||
char last;
|
||||
size_t len;
|
||||
|
||||
len = line->len;
|
||||
last = line->data[len - 1];
|
||||
@ -41,8 +42,9 @@ int ngx_parse_size(ngx_str_t *line)
|
||||
|
||||
int ngx_parse_time(ngx_str_t *line, int sec)
|
||||
{
|
||||
int value, total, len, scale;
|
||||
int value, total, scale;
|
||||
u_int max, i;
|
||||
size_t len;
|
||||
char *start, last;
|
||||
enum {
|
||||
st_start = 0,
|
||||
|
@ -101,7 +101,7 @@ ngx_module_t ngx_devpoll_module = {
|
||||
|
||||
static int ngx_devpoll_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
int n;
|
||||
size_t n;
|
||||
ngx_devpoll_conf_t *dpcf;
|
||||
|
||||
dpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_devpoll_module);
|
||||
@ -122,7 +122,7 @@ ngx_log_debug(cycle->log, "EV: %d" _ dpcf->events);
|
||||
if (max_changes < dpcf->changes) {
|
||||
if (nchanges) {
|
||||
n = nchanges * sizeof(struct pollfd);
|
||||
if (write(dp, change_list, n) != n) {
|
||||
if ((size_t) write(dp, change_list, n) != n) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"write(/dev/poll) failed");
|
||||
return NGX_ERROR;
|
||||
@ -271,7 +271,7 @@ static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
|
||||
{
|
||||
int n;
|
||||
size_t n;
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = ev->data;
|
||||
@ -286,7 +286,7 @@ static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
|
||||
"/dev/pool change list is filled up");
|
||||
|
||||
n = nchanges * sizeof(struct pollfd);
|
||||
if (write(dp, change_list, n) != n) {
|
||||
if ((size_t) write(dp, change_list, n) != n) {
|
||||
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
||||
"write(/dev/poll) failed");
|
||||
return NGX_ERROR;
|
||||
@ -306,7 +306,7 @@ static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
if (flags & NGX_CLOSE_EVENT) {
|
||||
n = nchanges * sizeof(struct pollfd);
|
||||
if (write(dp, change_list, n) != n) {
|
||||
if ((size_t) write(dp, change_list, n) != n) {
|
||||
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
||||
"write(/dev/poll) failed");
|
||||
return NGX_ERROR;
|
||||
@ -321,7 +321,8 @@ static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
{
|
||||
int events, n, i, j;
|
||||
int events, i, j;
|
||||
size_t n;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
@ -337,7 +338,7 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
delta = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
|
||||
} else {
|
||||
timer = INFTIM;
|
||||
timer = (ngx_msec_t) INFTIM;
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
@ -347,7 +348,7 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
|
||||
if (nchanges) {
|
||||
n = nchanges * sizeof(struct pollfd);
|
||||
if (write(dp, change_list, n) != n) {
|
||||
if ((size_t) write(dp, change_list, n) != n) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
"write(/dev/poll) failed");
|
||||
return NGX_ERROR;
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
|
||||
typedef struct {
|
||||
u_int changes;
|
||||
u_int events;
|
||||
int changes;
|
||||
int events;
|
||||
} ngx_kqueue_conf_t;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||
int ngx_kqueue = -1;
|
||||
|
||||
static struct kevent *change_list, *event_list;
|
||||
static u_int max_changes, nchanges, nevents;
|
||||
static int max_changes, nchanges, nevents;
|
||||
|
||||
|
||||
static ngx_str_t kqueue_name = ngx_string("kqueue");
|
||||
@ -196,8 +196,9 @@ static int ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
|
||||
ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
|
||||
|
||||
if (nchanges > 0
|
||||
&& ev->index < nchanges
|
||||
&& (void *) ((uintptr_t) change_list[ev->index].udata & ~1) == ev)
|
||||
&& ev->index < (u_int) nchanges
|
||||
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
|
||||
== (uintptr_t) ev)
|
||||
{
|
||||
c = ev->data;
|
||||
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
||||
@ -206,7 +207,7 @@ static int ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
return ngx_kqueue_set_event(ev, event, EV_ADD | flags);
|
||||
return ngx_kqueue_set_event(ev, event, EV_ADD|flags);
|
||||
}
|
||||
|
||||
|
||||
@ -217,8 +218,9 @@ static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
ev->active = 0;
|
||||
|
||||
if (nchanges > 0
|
||||
&& ev->index < nchanges
|
||||
&& (void *) ((uintptr_t) change_list[ev->index].udata & ~1) == ev)
|
||||
&& ev->index < (u_int) nchanges
|
||||
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
|
||||
== (uintptr_t) ev)
|
||||
{
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
ngx_connection_t *c = (ngx_connection_t *) ev->data;
|
||||
@ -228,7 +230,7 @@ static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
/* if the event is still not passed to a kernel we will not pass it */
|
||||
|
||||
if (ev->index < --nchanges) {
|
||||
if (ev->index < (u_int) --nchanges) {
|
||||
e = (ngx_event_t *) change_list[nchanges].udata;
|
||||
change_list[ev->index] = change_list[nchanges];
|
||||
e->index = ev->index;
|
||||
@ -247,7 +249,8 @@ static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
return ngx_kqueue_set_event(ev, event, EV_DELETE);
|
||||
return ngx_kqueue_set_event(ev, event,
|
||||
flags & NGX_DISABLE_EVENT ? EV_DISABLE : EV_DELETE);
|
||||
}
|
||||
|
||||
|
||||
@ -420,7 +423,7 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
|
||||
case EVFILT_WRITE:
|
||||
|
||||
instance = (uintptr_t) ev & 1;
|
||||
ev = (void *) ((uintptr_t) ev & ~1);
|
||||
ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1);
|
||||
|
||||
/*
|
||||
* it's a stale event from a file descriptor
|
||||
@ -486,8 +489,8 @@ static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
{
|
||||
ngx_kqueue_conf_t *kcf = conf;
|
||||
|
||||
ngx_conf_init_unsigned_value(kcf->changes, 512);
|
||||
ngx_conf_init_unsigned_value(kcf->events, 512);
|
||||
ngx_conf_init_value(kcf->changes, 512);
|
||||
ngx_conf_init_value(kcf->events, 512);
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ static int ngx_poll_process_events(ngx_log_t *log);
|
||||
|
||||
|
||||
static struct pollfd *event_list;
|
||||
static u_int nevents;
|
||||
static int nevents;
|
||||
|
||||
static ngx_event_t **event_index;
|
||||
static ngx_event_t **ready_index;
|
||||
@ -203,7 +203,7 @@ static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
#endif
|
||||
|
||||
if (e == NULL || e->index == NGX_INVALID_INDEX) {
|
||||
if (ev->index < --nevents) {
|
||||
if (ev->index < (u_int) --nevents) {
|
||||
event_list[ev->index] = event_list[nevents];
|
||||
event_index[ev->index] = event_index[nevents];
|
||||
event_index[ev->index]->index = ev->index;
|
||||
@ -222,8 +222,7 @@ static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
static int ngx_poll_process_events(ngx_log_t *log)
|
||||
{
|
||||
int ready, found, j;
|
||||
u_int nready, i;
|
||||
int i, j, ready, nready, found;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
@ -239,7 +238,7 @@ static int ngx_poll_process_events(ngx_log_t *log)
|
||||
delta = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
|
||||
} else {
|
||||
timer = INFTIM;
|
||||
timer = (ngx_msec_t) INFTIM;
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
@ -252,7 +251,7 @@ static int ngx_poll_process_events(ngx_log_t *log)
|
||||
ngx_log_debug(log, "poll timer: %d" _ timer);
|
||||
#endif
|
||||
|
||||
ready = poll(event_list, nevents, timer);
|
||||
ready = poll(event_list, (u_int) nevents, (int) timer);
|
||||
|
||||
if (ready == -1) {
|
||||
err = ngx_errno;
|
||||
|
@ -30,7 +30,7 @@ static int max_write;
|
||||
static int max_fd;
|
||||
#endif
|
||||
|
||||
static u_int nevents;
|
||||
static int nevents;
|
||||
|
||||
static ngx_event_t **event_index;
|
||||
static ngx_event_t **ready_index;
|
||||
@ -233,7 +233,7 @@ static int ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
#endif
|
||||
|
||||
if (ev->index < --nevents) {
|
||||
if (ev->index < (u_int) --nevents) {
|
||||
event_index[ev->index] = event_index[nevents];
|
||||
event_index[ev->index]->index = ev->index;
|
||||
}
|
||||
@ -247,8 +247,7 @@ static int ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
static int ngx_select_process_events(ngx_log_t *log)
|
||||
{
|
||||
int ready, found;
|
||||
u_int i, nready;
|
||||
int i, ready, nready,found;
|
||||
ngx_err_t err;
|
||||
ngx_msec_t timer;
|
||||
ngx_event_t *ev;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <ngx_core.h>
|
||||
|
||||
|
||||
#define NGX_INVALID_INDEX 0x80000000
|
||||
#define NGX_INVALID_INDEX 0xd0d0d0d0
|
||||
|
||||
|
||||
#if (HAVE_IOCP)
|
||||
@ -28,7 +28,7 @@ struct ngx_event_s {
|
||||
void *context;
|
||||
char *action;
|
||||
|
||||
unsigned int index;
|
||||
u_int index;
|
||||
|
||||
/* queue in mutex(), aio_read(), aio_write() */
|
||||
ngx_event_t *prev;
|
||||
@ -230,8 +230,9 @@ extern ngx_event_actions_t ngx_event_actions;
|
||||
#define NGX_CLOSE_EVENT 1
|
||||
|
||||
|
||||
/* this flag has meaning only for kqueue */
|
||||
/* these flags have a meaning only for kqueue */
|
||||
#define NGX_LOWAT_EVENT 0
|
||||
#define NGX_DISABLE_EVENT 0
|
||||
|
||||
|
||||
#if (HAVE_KQUEUE)
|
||||
@ -256,6 +257,9 @@ extern ngx_event_actions_t ngx_event_actions;
|
||||
#define NGX_ONESHOT_EVENT EV_ONESHOT
|
||||
#define NGX_CLEAR_EVENT EV_CLEAR
|
||||
|
||||
#undef NGX_DISABLE_EVENT
|
||||
#define NGX_DISABLE_EVENT EV_DISABLE
|
||||
|
||||
|
||||
#elif (HAVE_POLL)
|
||||
|
||||
@ -362,7 +366,7 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n);
|
||||
|
||||
|
||||
|
||||
ngx_inline static int ngx_handle_read_event(ngx_event_t *rev, int flags)
|
||||
ngx_inline static int ngx_handle_read_event(ngx_event_t *rev, u_int flags)
|
||||
{
|
||||
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
|
||||
|
||||
@ -432,7 +436,7 @@ ngx_inline static int ngx_handle_level_read_event(ngx_event_t *rev)
|
||||
}
|
||||
|
||||
|
||||
ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, int flags)
|
||||
ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, u_int flags)
|
||||
{
|
||||
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
||||
{
|
||||
int rc, instance, event;
|
||||
int rc, instance;
|
||||
u_int event;
|
||||
time_t now;
|
||||
ngx_err_t err;
|
||||
ngx_peer_t *peer;
|
||||
|
@ -19,7 +19,7 @@ static int ngx_event_pipe_drain_chains(ngx_event_pipe_t *p);
|
||||
|
||||
int ngx_event_pipe(ngx_event_pipe_t *p, int do_write)
|
||||
{
|
||||
int flags;
|
||||
u_int flags;
|
||||
ngx_event_t *rev, *wev;
|
||||
|
||||
for ( ;; ) {
|
||||
|
@ -185,6 +185,10 @@ int ngx_http_proxy_parse_status_line(ngx_http_proxy_ctx_t *p)
|
||||
return NGX_HTTP_PROXY_PARSE_NO_HEADER;
|
||||
}
|
||||
break;
|
||||
|
||||
/* suppress warning */
|
||||
case sw_done:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -936,6 +936,14 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
p->header_sent = 1;
|
||||
|
||||
if (p->cache && p->cache->ctx.file.fd != NGX_INVALID_FILE) {
|
||||
if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
|
||||
ngx_close_file_n " \"%s\" failed",
|
||||
p->cache->ctx.file.name.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (p->cachable) {
|
||||
header = (ngx_http_cache_header_t *) p->header_in->start;
|
||||
|
||||
|
@ -662,7 +662,7 @@ static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
||||
return rv;
|
||||
}
|
||||
|
||||
ngx_qsort(cscf->locations.elts, cscf->locations.nelts,
|
||||
ngx_qsort(cscf->locations.elts, (size_t) cscf->locations.nelts,
|
||||
sizeof(void *), ngx_cmp_locations);
|
||||
|
||||
return rv;
|
||||
|
@ -392,6 +392,10 @@ int ngx_http_parse_request_line(ngx_http_request_t *r)
|
||||
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
||||
}
|
||||
break;
|
||||
|
||||
/* suppress warning */
|
||||
case sw_done:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,6 +599,11 @@ int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h)
|
||||
return NGX_HTTP_PARSE_INVALID_HEADER;
|
||||
}
|
||||
break;
|
||||
|
||||
/* suppress warning */
|
||||
case sw_done:
|
||||
case sw_header_done:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1116,10 +1116,20 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
||||
wev = c->write;
|
||||
wev->event_handler = ngx_http_empty_handler;
|
||||
|
||||
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && wev->active) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
if (wev->active) {
|
||||
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1218,11 +1228,20 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r)
|
||||
wev = c->write;
|
||||
wev->event_handler = ngx_http_empty_handler;
|
||||
|
||||
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && wev->active) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
||||
ngx_http_close_request(r, 0);
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
if (wev->active) {
|
||||
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
|
||||
if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,8 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
|
||||
|
||||
if (cl->next == NULL) {
|
||||
return ngx_write_file(file, cl->hunk->pos,
|
||||
cl->hunk->last - cl->hunk->pos, offset);
|
||||
(size_t) (cl->hunk->last - cl->hunk->pos),
|
||||
offset);
|
||||
}
|
||||
|
||||
prev = NULL;
|
||||
|
@ -82,7 +82,7 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
|
||||
#define ngx_read_dir_n "readdir()"
|
||||
|
||||
|
||||
#define ngx_create_dir(name) mkdir(name, 0700)
|
||||
#define ngx_create_dir(name) mkdir(name, (mode_t) 0700)
|
||||
#define ngx_create_dir_n "mkdir()"
|
||||
|
||||
|
||||
|
@ -31,13 +31,19 @@
|
||||
/* TODO: autoconf */
|
||||
#if (i386)
|
||||
|
||||
#if 0
|
||||
#define OFF_FMT "%lld"
|
||||
#endif
|
||||
|
||||
#define SIZE_FMT "%d"
|
||||
#define SIZEX_FMT "%x"
|
||||
|
||||
#else /* amd64, alpha, sparc64, ia64 */
|
||||
|
||||
#if 0
|
||||
#define OFF_FMT "%ld"
|
||||
#endif
|
||||
|
||||
#define SIZE_FMT "%ld"
|
||||
#define SIZEX_FMT "%lx"
|
||||
|
||||
|
@ -25,7 +25,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in)
|
||||
int rc, eintr, eagain;
|
||||
char *prev;
|
||||
off_t sent, fprev;
|
||||
ssize_t hsize, fsize, size;
|
||||
size_t hsize, fsize, size;
|
||||
struct iovec *iov;
|
||||
struct sf_hdtr hdtr;
|
||||
ngx_err_t err;
|
||||
|
Loading…
Reference in New Issue
Block a user