Welcome! Log In Create A New Profile

Advanced

Re: Internals: how do I send large file to the client?

August 14, 2013 08:30AM
I know those commands. But the question was about Nginx's internals. I thought
somebody would suggest a pseudo-code snippet similar to the following:

ngx_buf_t b;
size_t length = 0;

loop (files as file) {
...

u_char *filename = file->name;

if (ngx_open_cached_file(ccf->open_file_cache, filename, &of, r->pool)
!= NGX_OK)
return NGX_ERROR;

length += of.size;

b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
if (b == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
if (b->file == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

b->file_pos = 0;
b->file_last = of.size;
b->in_file = b->file_last ? 1 : 0;
b->file->fd = of.fd;
b->file->name = *filename;
b->file->log = r->connection->log;
b->file->directio = of.is_directio;

cl = ngx_alloc_chain_link(r->pool);
if (cl == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
cl->buf = b;

*last_out = cl;
last_out = &cl->next;
cl->next = NULL;

...
}

I've found ngx_open_cached_file and ngx_alloc_chain_link just recently. I see,
there should be a way to chain open files without actually performing I/O
myself. Still have no clear understanding how it works and how one should use
the cached files' API.

coolbhushans@gmail.com Wrote:
-------------------------------------------------------
> have u know the split command in linux . you can use that to split
> file
> then send it after you can use join command to join files
>
Subject Author Posted

Internals: how do I send large file to the client?

ruslan_osmanov August 12, 2013 03:30PM

Re: Internals: how do I send large file to the client?

coolbhushans@gmail.com August 14, 2013 08:10AM

Re: Internals: how do I send large file to the client?

ruslan_osmanov August 14, 2013 08:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 138
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