0
我正在写nginx模块,它构造nginx链,然后将此链缓冲区写入nginx临时文件以稍后使用它(刚刚写入后)。我一直在寻找每一个页面,唯一的解决办法拿出的是一个波纹管:如何正确使用ngx_write_chain_to_temp_file?
// Create temp file to test
ngx_temp_file_t *tf;
tf = ngx_pcalloc(r->pool, sizeof (ngx_temp_file_t));
if (tf == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
tf->file.fd = NGX_INVALID_FILE;
tf->file.log = nlog;
tf->path = clcf->client_body_temp_path;
tf->pool = r->pool;
tf->log_level = r->request_body_file_log_level;
tf->persistent = r->request_body_in_persistent_file;
tf->clean = r->request_body_in_clean_file;
// if (r->request_body_file_group_access) {
// tf->access = 0660;
// }
if (ngx_create_temp_file(&tf->file, tf->path, tf->pool, tf->persistent, tf->clean, tf->access) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
if (ngx_write_chain_to_temp_file(tf, bucket->first) == NGX_ERROR) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
此代码不会返回NGX_ERROR,那是不是意味着nginx的成功写入临时文件到client_body_temporay_path?答案是肯定的,之后我用fopen打开文件,文件不存在?
任何人都可以请给我正确的解决方案来处理ngx_write_chain_to_temp_file?