[njs] Fixed closing file descriptor on error.

2016-07-21 Thread Roman Arutyunyan
details:   http://hg.nginx.org/njs/rev/1cfc38ab7ba1
branches:  
changeset: 127:1cfc38ab7ba1
user:  Roman Arutyunyan 
date:  Thu Jul 21 11:39:00 2016 +0300
description:
Fixed closing file descriptor on error.

Found by Coverity (CID 1364196, 1364197, 1364198, 1364199).

diffstat:

 nginx/ngx_http_js_module.c   |  6 --
 nginx/ngx_stream_js_module.c |  8 +---
 2 files changed, 9 insertions(+), 5 deletions(-)

diffs (76 lines):

diff -r faab537db6f8 -r 1cfc38ab7ba1 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.cWed Jul 20 21:40:34 2016 +0300
+++ b/nginx/ngx_http_js_module.cThu Jul 21 11:39:00 2016 +0300
@@ -1249,6 +1249,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
   ngx_fd_info_n " \"%s\" failed", file.data);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
@@ -1256,6 +1257,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
 
 start = ngx_pnalloc(cf->pool, size);
 if (start == NULL) {
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
@@ -1265,7 +1267,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
   ngx_read_fd_n " \"%s\" failed", file.data);
 
-ngx_close_file(fd);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
@@ -1274,7 +1276,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
   ngx_read_fd_n " has read only %z of %O from \"%s\"",
   n, size, file.data);
 
-ngx_close_file(fd);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
diff -r faab537db6f8 -r 1cfc38ab7ba1 nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c  Wed Jul 20 21:40:34 2016 +0300
+++ b/nginx/ngx_stream_js_module.c  Thu Jul 21 11:39:00 2016 +0300
@@ -456,6 +456,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
   ngx_fd_info_n " \"%s\" failed", file.data);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
@@ -463,6 +464,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
 
 start = ngx_pnalloc(cf->pool, size);
 if (start == NULL) {
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
@@ -472,16 +474,16 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
   ngx_read_fd_n " \"%s\" failed", file.data);
 
-ngx_close_file(fd);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 
 if ((size_t) n != size) {
 ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
-  ngx_read_fd_n " has read only %z of %O from \"%s\"",
+  ngx_read_fd_n " has read only %z of %uz from \"%s\"",
   n, size, file.data);
 
-ngx_close_file(fd);
+(void) ngx_close_file(fd);
 return NGX_CONF_ERROR;
 }
 

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


Re: [PATCH 1 of 2] HTTP: add support for trailers in HTTP responses

2016-07-21 Thread Maxim Dounin
Hello!

On Wed, Jul 20, 2016 at 06:33:11PM -0700, Alexey Ivanov wrote:

> 
> > On Jul 20, 2016, at 6:23 PM, Maxim Dounin  wrote:
> > 
> > Hello!
> > 
> > On Wed, Jul 20, 2016 at 03:34:46PM -0700, Alexey Ivanov wrote:
> > 
> >> Speaking of trailers: we had couple of use cases for HTTP
> >> trailers, most of them were around streaming data to user.
> >> 
> >> For example, when webpage is generated we send headers and part
> >> of the body(usually up to ``) almost immediately, but
> >> then we start querying all the micro services for the content
> >> (SOA, yay!).
> >> The problem is that upstreams will inevitably fail/timeout, and
> >> when that happens there is no way to pass any metadata about the
> >> error to nginx, since headers are already sent. Using trailers
> >> here may improve MTTR since backend metadata is available on the
> >> frontend.
> >> 
> >> Another example may be computing checksums for data while you
> >> stream it and putting it in the trailer. This should reduce TTFB
> >> by quite a lot on some workloads we have.
> > 
> > Do you actually use something like this, or know places where
> > something like this is actually used?
> These are examples from our production. Currently we are using 
> workarounds for both of these problems. Though I'm not sure that 
> we would use trailers if they were supported, since it's one of 
> very obscure HTTP/1.1 features that people do not usually know 
> about.
> 
> That is starting to change bit by bit though, since people try 
> using gRPC more and more.

Could you please elaborate what exactly you do use now and if you 
know any examples of trailers being used instead?

-- 
Maxim Dounin
http://nginx.org/

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


how i can use third party library while building own nginx module

2016-07-21 Thread Pankaj Chaudhary
Hi,

how i can use third party library while building own nginx module as i am
using third party libraries.

Thanks,
Pankaj
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel