2014-09-22 2 views
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를 반환하지 않습니다,이 client_body_temporay_path에 nginx를 성공적으로 쓰기 임시 파일을 의미한다 : 나는 모든 페이지 및 유일한 해결책이 마련 검색 봤는데 울부 짖는 사람은? 그 대답은 네, 그 후, 나는 파일을 열려면 fopen을 사용하고, 그 파일은 존재하지 않습니까?

아무에게도 ngx_write_chain_to_temp_file을 (를) 처리하는 데 올바른 해결책을 제공 할 수 있습니까?

답변

1

나는 나 자신에게 해결책을 찾기

 ngx_temp_file_t *tf; 
     tf = ngx_pcalloc(r->pool, sizeof (ngx_temp_file_t)); 
     tf->file.fd = NGX_INVALID_FILE; 
     tf->file.log = nlog; 
     tf->path = clcf->client_body_temp_path; 
     tf->pool = r->pool; 
     tf->persistent = 1; 
     rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool, tf->persistent, tf->clean, tf->access); 
     //ngx_write_chain_to_file(&tf->file, bucket->first, bucket->content_length, r->pool); 
     ngx_write_chain_to_temp_file(tf, bucket->first); 

내가 전달되지 했더라도 내가 파일을 만든 후 (0), 나는 그것을 읽을 수 없습니다 false로 tf->persistent를 설정하면 내가 이해할 수있는 유일한 방법입니다 output_filter에 대한 응답이 아직 없습니다.

관련 문제