Skip to content

Commit 7296908

Browse files
authored
perf: avoid copy if possible (#44)
1 parent 0775c0f commit 7296908

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

patch/1.19.9/ngx_stream_lua-xrpc.patch

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git src/ngx_stream_lua_socket_tcp.c src/ngx_stream_lua_socket_tcp.c
2-
index 7fcfb45..8fc96cf 100644
2+
index 7fcfb45..3178588 100644
33
--- src/ngx_stream_lua_socket_tcp.c
44
+++ src/ngx_stream_lua_socket_tcp.c
55
@@ -234,6 +234,41 @@ enum {
@@ -44,7 +44,7 @@ index 7fcfb45..8fc96cf 100644
4444

4545
static char ngx_stream_lua_raw_req_socket_metatable_key;
4646
static char ngx_stream_lua_tcp_socket_metatable_key;
47-
@@ -6005,6 +6040,576 @@ static ngx_int_t ngx_stream_lua_socket_insert_buffer(
47+
@@ -6005,6 +6040,582 @@ static ngx_int_t ngx_stream_lua_socket_insert_buffer(
4848
}
4949

5050

@@ -506,10 +506,16 @@ index 7fcfb45..8fc96cf 100644
506506
+ return NGX_DONE;
507507
+ }
508508
+
509-
+ /* TODO: avoid copying (it requires to modify the way cosocket sends data) */
510-
+ for (in_cl = src->bufs_in; in_cl; in_cl = in_cl->next) {
511-
+ b = in_cl->buf;
512-
+ cl->buf->last = ngx_copy(cl->buf->last, b->pos, b->last - b->pos);
509+
+ if (!src->bufs_in->next) {
510+
+ cl->buf->pos = src->bufs_in->buf->pos;
511+
+ cl->buf->last = src->bufs_in->buf->last;
512+
+
513+
+ } else {
514+
+ /* TODO: avoid copying (it requires to modify the way cosocket sends data) */
515+
+ for (in_cl = src->bufs_in; in_cl; in_cl = in_cl->next) {
516+
+ b = in_cl->buf;
517+
+ cl->buf->last = ngx_copy(cl->buf->last, b->pos, b->last - b->pos);
518+
+ }
513519
+ }
514520
+
515521
+ ngx_stream_lua_ffi_socket_reset_buf(ctx, src);

0 commit comments

Comments
 (0)