Skip to content

Commit

Permalink
Minor changes according to the latest code review.
Browse files Browse the repository at this point in the history
- Eliminate the "source" part of an error message. Not needed now.
- Eliminate static global constant strings. Use strings in place.
- Rename tfw_http_req_move2equeue() to a shorter tfw_http_req_error().
- tfw_http_req_init_ss_flags() now set to copy all SKBs. Make a TODO.
- Better comment to tfw_http_conn_evict_timeout().
  • Loading branch information
keshonok committed Mar 2, 2017
1 parent 50ade60 commit 8273de0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 81 deletions.
16 changes: 5 additions & 11 deletions tempesta_fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#warning "Please set CONFIG_NODES_SHIFT to less than 16"
#endif

extern const char *s_source_cache;

/* Flags stored in a Cache Entry. */
#define TFW_CE_MUST_REVAL 0x0001 /* MUST revalidate if stale. */

Expand Down Expand Up @@ -937,28 +935,24 @@ tfw_cache_purge_method(TfwHttpReq *req)

/* Deny PURGE requests by default. */
if (!(cache_cfg.cache && vhost->cache_purge && vhost->cache_purge_acl))
return tfw_http_send_403(req, s_source_cache,
"purge: not configured");
return tfw_http_send_403(req, "purge: not configured");

/* Accept requests from configured hosts only. */
ss_getpeername(req->conn->sk, &saddr);
if (!tfw_capuacl_match(vhost, &saddr))
return tfw_http_send_403(req, s_source_cache,
"purge: ACL violation");
return tfw_http_send_403(req, "purge: ACL violation");

/* Only "invalidate" option is implemented at this time. */
switch (vhost->cache_purge_mode) {
case TFW_D_CACHE_PURGE_INVALIDATE:
ret = tfw_cache_purge_invalidate(req);
break;
default:
return tfw_http_send_403(req, s_source_cache,
"purge: invalid option");
return tfw_http_send_403(req, "purge: invalid option");
}

return ret
? tfw_http_send_404(req, s_source_cache,
"purge: processing error")
? tfw_http_send_404(req, "purge: processing error")
: tfw_http_send_200(req);
}

Expand Down Expand Up @@ -1214,7 +1208,7 @@ cache_req_process_node(TfwHttpReq *req, tfw_http_cache_cb_t action)
resp->flags |= TFW_HTTP_RESP_STALE;
out:
if (!resp && (req->cache_ctl.flags & TFW_HTTP_CC_OIFCACHED))
tfw_http_send_504(req, s_source_cache, "resource not cached");
tfw_http_send_504(req, "resource not cached");
else
action(req, resp);

Expand Down
Loading

0 comments on commit 8273de0

Please sign in to comment.