Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed the compatible problem with nginx-1.3.10

most of the changes are in the tcp log module
  • Loading branch information...
commit fcf15274340ba70b42aa145b84f2973484b49ced 1 parent ae321fd
@yaoweibin authored
Showing with 83 additions and 10 deletions.
  1. +6 −0 ngx_tcp.h
  2. +47 −9 ngx_tcp_core_module.c
  3. +30 −1 ngx_tcp_log.c
View
6 ngx_tcp.h
@@ -157,6 +157,12 @@ typedef struct {
} ngx_tcp_log_t;
typedef struct {
+ u_char *start;
+ u_char *pos;
+ u_char *last;
+} ngx_tcp_log_buf_t;
+
+typedef struct {
ngx_array_t *logs; /* array of ngx_tcp_log_t */
ngx_open_file_cache_t *open_file_cache;
View
56 ngx_tcp_core_module.c
@@ -790,9 +790,12 @@ ngx_tcp_log_set_access_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_tcp_core_srv_conf_t *cscf = conf;
ngx_tcp_log_srv_conf_t *lscf = cscf->access_log;
- ssize_t buf;
+ ssize_t size;
ngx_str_t *value, name;
ngx_tcp_log_t *log;
+#if (nginx_version) >= 1003010
+ ngx_tcp_log_buf_t *buffer;
+#endif
value = cf->args->elts;
@@ -836,28 +839,63 @@ ngx_tcp_log_set_access_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
name.len = value[2].len - 7;
name.data = value[2].data + 7;
- buf = ngx_parse_size(&name);
+ size = ngx_parse_size(&name);
- if (buf == NGX_ERROR) {
+ if (size == NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid parameter \"%V\"", &value[2]);
return NGX_CONF_ERROR;
}
- if (log->file->buffer && log->file->last - log->file->pos != buf) {
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "access_log \"%V\" already defined "
- "with different buffer size", &value[1]);
+#if (nginx_version) >= 1003010
+ if (log->file->data) {
+
+ buffer = log->file->data;
+
+ if (buffer->last - buffer->pos != size) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "access_log \"%V\" already defined "
+ "with different buffer size", &value[1]);
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+ }
+
+ buffer = ngx_pcalloc(cf->pool, sizeof(ngx_tcp_log_buf_t));
+ if (buffer == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ buffer->start = ngx_palloc(cf->pool, size);
+ if (buffer->start == NULL) {
return NGX_CONF_ERROR;
}
- log->file->buffer = ngx_palloc(cf->pool, buf);
+ buffer->pos = buffer->start;
+ buffer->last = buffer->start + size;
+
+ log->file->data = buffer;
+#else
+ if (log->file->buffer) {
+ if (log->file->last - log->file->pos != size) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "access_log \"%V\" already defined "
+ "with different buffer size", &value[1]);
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+ }
+
+ log->file->buffer = ngx_palloc(cf->pool, size);
if (log->file->buffer == NULL) {
return NGX_CONF_ERROR;
}
log->file->pos = log->file->buffer;
- log->file->last = log->file->buffer + buf;
+ log->file->last = log->file->buffer + size;
+#endif
}
return NGX_CONF_OK;
View
31 ngx_tcp_log.c
@@ -20,7 +20,10 @@ ngx_tcp_log_handler(ngx_tcp_session_t *s)
ngx_connection_t *c;
ngx_tcp_log_t *log;
ngx_open_file_t *file;
- ngx_tcp_log_srv_conf_t *lscf;
+ #if (nginx_version) >= 1003010
+ ngx_tcp_log_buf_t *buffer;
+#endif
+ ngx_tcp_log_srv_conf_t *lscf;
ngx_tcp_core_srv_conf_t *cscf;
ngx_log_debug0(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
@@ -63,6 +66,31 @@ ngx_tcp_log_handler(ngx_tcp_session_t *s)
file = log[l].file;
+#if (nginx_version) >= 1003010
+ if (file && file->data) {
+
+ buffer = file->data;
+
+ if (len > (size_t) (buffer->last - buffer->pos)) {
+
+ ngx_tcp_log_write(s, &log[l], buffer->start,
+ buffer->pos - buffer->start);
+
+ buffer->pos = buffer->start;
+ }
+
+ if (len <= (size_t) (buffer->last - buffer->pos)) {
+
+ p = buffer->pos;
+
+ p = ngx_tcp_log_fill(s, p);
+
+ buffer->pos = p;
+
+ continue;
+ }
+ }
+#else
if (file && file->buffer) {
if (len > (size_t) (file->last - file->pos)) {
@@ -84,6 +112,7 @@ ngx_tcp_log_handler(ngx_tcp_session_t *s)
continue;
}
}
+#endif
line = ngx_pnalloc(s->pool, len);
if (line == NULL) {
Please sign in to comment.
Something went wrong with that request. Please try again.