diff options
-rw-r--r-- | auto/cc | 10 | ||||
-rw-r--r-- | src/event/ngx_event_spinlock.c | 26 | ||||
-rw-r--r-- | src/http/ngx_http_write_filter.c | 3 | ||||
-rw-r--r-- | src/os/win32/ngx_os.h | 9 | ||||
-rw-r--r-- | src/os/win32/ngx_win32_config.h | 17 | ||||
-rw-r--r-- | src/os/win32/ngx_wsasend_chain.c | 6 |
6 files changed, 59 insertions, 12 deletions
@@ -7,7 +7,7 @@ case $CC in # gcc 2.7.2.3, 2.8.1, 2.95.4, # 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4 - # optimization + # optimizations #CFLAGS="$CFLAGS -O2 -fomit-frame-pointer" case $CPU in @@ -92,7 +92,7 @@ case $CC in *icc) # Intel C++ compiler 7.1, 8.0 - # optimization + # optimizations CFLAGS="$CFLAGS -O" # inline functions declared with __inline #CFLAGS="$CFLAGS -Ob1" @@ -165,7 +165,7 @@ case $CC in cl) # MSVC 6.0 SP2 - # optimization + # optimizations # maximize speed CFLAGS="$CFLAGS -O2" @@ -244,7 +244,7 @@ case $CC in wcl386) # Open Watcom C 1.0, 1.2 - # optimization + # optimizations # maximize speed CFLAGS="$CFLAGS -ot" @@ -325,7 +325,7 @@ case $CC in bcc32) # Borland C++ 5.5 - # optimization + # optimizations # maximize speed CFLAGS="$CFLAGS -O2" diff --git a/src/event/ngx_event_spinlock.c b/src/event/ngx_event_spinlock.c new file mode 100644 index 000000000..58edb2af5 --- /dev/null +++ b/src/event/ngx_event_spinlock.c @@ -0,0 +1,26 @@ + + +void _spinlock(ngx_atomic_t *lock) +{ + ngx_int_t tries; + + tries = 0; + + for ( ;; ) { + + if (*lock) { + if (ngx_ncpu > 1 && tries++ < 1000) { + continue; + } + + sched_yield(); + tries = 0; + + } else { + if (ngx_atomic_cmp_set(lock, 0, 1)) { + return; + } + } + } +} + diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c index f82bdaede..2d4ba23bb 100644 --- a/src/http/ngx_http_write_filter.c +++ b/src/http/ngx_http_write_filter.c @@ -162,7 +162,8 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) if (conf->limit_rate) { sent = r->connection->sent - sent; r->connection->write->delayed = 1; - ngx_add_timer(r->connection->write, sent * 1000 / conf->limit_rate); + ngx_add_timer(r->connection->write, + (ngx_msec_t) sent * 1000 / conf->limit_rate); } if (chain == NGX_CHAIN_ERROR) { diff --git a/src/os/win32/ngx_os.h b/src/os/win32/ngx_os.h index 2fae21b84..aa66e70d3 100644 --- a/src/os/win32/ngx_os.h +++ b/src/os/win32/ngx_os.h @@ -26,7 +26,8 @@ typedef struct { ssize_t (*recv)(ngx_connection_t *c, u_char *buf, size_t size); ssize_t (*recv_chain)(ngx_connection_t *c, ngx_chain_t *in); ssize_t (*send)(ngx_connection_t *c, u_char *buf, size_t size); - ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in); + ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in, + off_t limit); int flags; } ngx_os_io_t; @@ -36,8 +37,10 @@ int ngx_os_init(ngx_log_t *log); ssize_t ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size); ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size); ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain); -ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in); -ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in); +ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, + off_t limit); +ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, + off_t limit); extern ngx_os_io_t ngx_os_io; diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index cc3a06842..72e5c5e79 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -30,16 +30,28 @@ /* disable some "-W4" level warnings */ -#pragma warning(disable:4054) +/* disable warnings about some 'type cast */ #pragma warning(disable:4054) #pragma warning(disable:4055) + /* unreferenced formal parameter */ #pragma warning(disable:4100) + +/* conditional expression is constant */ #pragma warning(disable:4127) + +/* nonstandard extension used : bit field types other than int */ #pragma warning(disable:4214) + +/* unreachable code */ #pragma warning(disable:4702) + +/* assignment within conditional expression */ #pragma warning(disable:4706) +/* disable "function 'ngx_handle_write_event' not inlined" */ +#pragma warning(disable:4710) + #endif @@ -121,6 +133,9 @@ typedef uint32_t ngx_atomic_t; #endif +#define OFF_T_MAX_VALUE 9223372036854775807 + + /* STUB */ #define HAVE_LITTLE_ENDIAN 1 diff --git a/src/os/win32/ngx_wsasend_chain.c b/src/os/win32/ngx_wsasend_chain.c index 4ada9ea4e..eda422ed2 100644 --- a/src/os/win32/ngx_wsasend_chain.c +++ b/src/os/win32/ngx_wsasend_chain.c @@ -4,7 +4,8 @@ #include <ngx_event.h> -ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in) +ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, + off_t limit) { int rc; u_char *prev; @@ -99,7 +100,8 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in) } -ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in) +ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, + off_t limit) { int rc; u_char *prev; |