Skip to content

Commit

Permalink
Merge commit '06762d10b223e06402e14d8a428900aa597e0d68' into for-c-dr…
Browse files Browse the repository at this point in the history
…iver-v0.4

Conflicts:
	ngx_http_gridfs_module.c

modified MONGO_TRY_GENERIC macro.
  • Loading branch information
kiwanami committed Sep 28, 2011
2 parents 652bb77 + 06762d1 commit 1c1871f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ngx_http_gridfs_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
ngx_log_error(NGX_LOG_ERR, request->connection->log, 0,
"Mongo connection dropped, could not reconnect");
if(&mongo_conn->conn.connected) { mongo_disconnect(&mongo_conn->conn); }
free(value);
return NGX_HTTP_SERVICE_UNAVAILABLE;
}
}
Expand All @@ -782,6 +783,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
free(value);

if(status == MONGO_ERROR) {
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_NOT_FOUND;
}

Expand All @@ -806,6 +809,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
ngx_log_error(NGX_LOG_ERR, request->connection->log, 0, gridfile_get_field(&gfile,"gzipped") );
request->headers_out.content_encoding = ngx_list_push(&request->headers_out.headers);
if (request->headers_out.content_encoding == NULL) {
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_ERROR;
}
request->headers_out.content_encoding->hash = 1;
Expand All @@ -826,6 +831,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
if (buffer == NULL) {
ngx_log_error(NGX_LOG_ERR, request->connection->log, 0,
"Failed to allocate response buffer");
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Expand All @@ -835,11 +842,17 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
buffer->last_buf = 1;
out.buf = buffer;
out.next = NULL;

gridfile_destroy(&gfile);
gridfs_destroy(&gfs);

return ngx_http_output_filter(request, &out);
}

cursors = (mongo_cursor **)ngx_pcalloc(request->pool, sizeof(mongo_cursor *) * numchunks);
if (cursors == NULL) {
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Expand All @@ -848,6 +861,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
/* Hook in the cleanup function */
gridfs_cln = ngx_pool_cleanup_add(request->pool, sizeof(ngx_http_gridfs_cleanup_t));
if (gridfs_cln == NULL) {
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
gridfs_cln->handler = ngx_http_gridfs_cleanup;
Expand All @@ -863,6 +878,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
if (buffer == NULL) {
ngx_log_error(NGX_LOG_ERR, request->connection->log, 0,
"Failed to allocate response buffer");
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Expand All @@ -878,6 +895,8 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {
ngx_log_error(NGX_LOG_ERR, request->connection->log, 0,
"Mongo connection dropped, could not reconnect");
if(&mongo_conn->conn.connected) { mongo_disconnect(&mongo_conn->conn); }
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_HTTP_SERVICE_UNAVAILABLE;
}
}
Expand All @@ -901,10 +920,15 @@ static ngx_int_t ngx_http_gridfs_handler(ngx_http_request_t* request) {

/* TODO: More Codes to Catch? */
if (rc == NGX_ERROR) {
gridfile_destroy(&gfile);
gridfs_destroy(&gfs);
return NGX_ERROR;
}
}

gridfile_destroy(&gfile);
gridfs_destroy(&gfs);

return rc;
}

Expand Down

0 comments on commit 1c1871f

Please sign in to comment.