summaryrefslogtreecommitdiffhomepage
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-09-21 17:14:17 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-09-25 17:39:43 +0100
commit43c8e44d33572b818cdd0a5945e494c5510ab24f (patch)
tree24369b22c30fb348ffb9765db423588ef5ca6d7f /CONTRIBUTING.md
parent1dd1b34194573661b10015fbc60d6910dbea8fcc (diff)
downloadunit-wasm-43c8e44d33572b818cdd0a5945e494c5510ab24f.tar.gz
unit-wasm-43c8e44d33572b818cdd0a5945e494c5510ab24f.tar.bz2
libunit-wasm: Add a luw_mem_splice_file() function
This is inspired by the likes of splice(2) and sendfile(2) in that it takes data from one place and puts it in another. This function write(2)'s the request data straight from the shared memory to a given file (referenced by its file descriptor). This is an alternative to using luw_req_buf_copy() and avoids an extra copying of the request data. E.g /* In the request_handler */ if (total_bytes_wrote == 0) { luw_init_ctx(&ctx, addr, 0); luw_set_req_buf(&ctx, &request_buf, LUW_SRB_NONE); fd = open("/var/tmp/large-file.dat", O_CREAT|O_TRUNC|O_WRONLY, 0666); } total_bytes_wrote += luw_mem_splice_file(addr, fd); if (total_bytes_wrote == luw_get_http_content_len(&ctx)) { close(fd); total_bytes_wrote = 0; luw_http_response_end(); } NOTE: We include a typedef definition for ssize_t in unit-wasm.h, to avoid having a dependency on the wasi-sysroot when generating the rust bindings. ssize_t is defined in sys/types.h which is provided by libc and not the compiler. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'CONTRIBUTING.md')
0 files changed, 0 insertions, 0 deletions