Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 4] Fix socket leak with AIO

Maxim Dounin
October 11, 2010 09:06AM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1286631445 -14400
# Node ID 38a938ce08300bb57d0f6c885b1d8c35d602419d
# Parent 94b30aa5d8497cc409579f3253dfa3522c55a28b
Fix socket leak with AIO.

When output buffer size was less than file size we are going to send second
aio post happened if non-first aio operation on the file in question was not
able to complete immediately.

Additionally, on Linux aio event's ready flag wasn't reset after submitting
io request, and as a result there were no "[alert] ... second aio post"
messages.

diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -74,18 +74,18 @@ ngx_output_chain(ngx_output_chain_ctx_t
}
}

-#if (NGX_HAVE_FILE_AIO)
- if (ctx->aio) {
- return NGX_AGAIN;
- }
-#endif
-
out = NULL;
last_out = &out;
last = NGX_NONE;

for ( ;; ) {

+#if (NGX_HAVE_FILE_AIO)
+ if (ctx->aio) {
+ return NGX_AGAIN;
+ }
+#endif
+
while (ctx->in) {

/*
diff --git a/src/http/ngx_http_copy_filter_module.c b/src/http/ngx_http_copy_filter_module.c
--- a/src/http/ngx_http_copy_filter_module.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -211,6 +211,8 @@ ngx_http_copy_aio_handler(ngx_output_cha

r->main->blocked++;
r->aio = 1;
+
+ ctx->aio = 1;
}


diff --git a/src/os/unix/ngx_linux_aio_read.c b/src/os/unix/ngx_linux_aio_read.c
--- a/src/os/unix/ngx_linux_aio_read.c
+++ b/src/os/unix/ngx_linux_aio_read.c
@@ -95,6 +95,10 @@ ngx_file_aio_read(ngx_file_t *file, u_ch
n = io_submit(ngx_aio_ctx, 1, piocb);

if (n == 1) {
+ ev->active = 1;
+ ev->ready = 0;
+ ev->complete = 0;
+
return NGX_AGAIN;
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1 of 4] Fix socket leak with AIO

Maxim Dounin 2608 October 11, 2010 09:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready