Skip to content

Instantly share code, notes, and snippets.

Created May 14, 2012 15:14
Show Gist options
  • Save anonymous/2694514 to your computer and use it in GitHub Desktop.
Save anonymous/2694514 to your computer and use it in GitHub Desktop.
patch for ignoring tracking id already registered
--- ngx_http_uploadprogress_module_ori.c 2012-05-14 14:10:18.000000000 +0200
+++ ngx_http_uploadprogress_module.c 2012-05-14 17:23:36.000000000 +0200
@@ -66,6 +66,7 @@
ngx_array_t templates;
ngx_str_t header;
ngx_str_t jsonp_parameter;
+ ngx_flag_t noerror_if_exist;
} ngx_http_uploadprogress_conf_t;
typedef struct {
@@ -174,6 +175,13 @@
offsetof(ngx_http_uploadprogress_conf_t, jsonp_parameter),
NULL},
+ {ngx_string("upload_progress_noerror_if_exist"),
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uploadprogress_conf_t, noerror_if_exist),
+ NULL},
+
ngx_null_command
};
@@ -799,13 +807,23 @@
if (find_node(id, ctx, r->connection->log) != NULL) {
ngx_shmtx_unlock(&shpool->mutex);
/* already found a node with matching progress ID */
+
+
+ if (upcf->noerror_if_exist) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "upload_progress: tracking already registered id: %V", id);
+ "upload_progress: ignoring tracking already registered id: %V", id);
+ ngx_free(id);
+ return NGX_DECLINED;
+ } else {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "upload_progress: tracking already registered id: %V", id);
ngx_free(id);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
+ }
+
cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_http_uploadprogress_cleanup_t));
if (cln == NULL) {
ngx_shmtx_unlock(&shpool->mutex);
@@ -1250,6 +1268,8 @@
return NGX_CONF_ERROR;
}
+ conf->noerror_if_exist = NGX_CONF_UNSET;
+
if(ngx_array_init(&conf->templates, cf->pool, 4, sizeof(ngx_http_uploadprogress_template_t)) != NGX_OK) {
return NGX_CONF_ERROR;
}
@@ -1284,6 +1304,11 @@
conf->track = prev->track;
}
+ if (conf->noerror_if_exist == NGX_CONF_UNSET) {
+ conf->noerror_if_exist = (prev->noerror_if_exist != NGX_CONF_UNSET) ?
+ prev->noerror_if_exist : 0;
+ }
+
ngx_conf_merge_str_value(conf->content_type, prev->content_type, "text/javascript");
t = conf->templates.elts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment