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?