[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
h2o_get_timestamp is no longer needed to return struct timeval, so le…
Browse files Browse the repository at this point in the history
…t it simply return h2o_timestamp_t
  • Loading branch information
i110 committed Apr 11, 2018
1 parent 67a1034 commit ca48f3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 7 additions & 8 deletions include/h2o.h
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ void h2o_context_dispose_pathconf_context(h2o_context_t *ctx, h2o_pathconf_t *pa
* @param ts buffer to store the timestamp (optional)
* @return current time in UTC
*/
static struct timeval *h2o_get_timestamp(h2o_context_t *ctx, h2o_mem_pool_t *pool, h2o_timestamp_t *ts);
static h2o_timestamp_t h2o_get_timestamp(h2o_context_t *ctx, h2o_mem_pool_t *pool);
void h2o_context_update_timestamp_cache(h2o_context_t *ctx);
/**
* returns per-module context set
Expand Down Expand Up @@ -2127,17 +2127,16 @@ inline void h2o_setup_next_prefilter(h2o_req_prefilter_t *self, h2o_req_t *req,
h2o_setup_next_ostream(req, slot);
}

inline struct timeval *h2o_get_timestamp(h2o_context_t *ctx, h2o_mem_pool_t *pool, h2o_timestamp_t *ts)
inline h2o_timestamp_t h2o_get_timestamp(h2o_context_t *ctx, h2o_mem_pool_t *pool)
{
h2o_context_update_timestamp_cache(ctx);

if (ts != NULL) {
ts->at = ctx->_timestamp_cache.tv_at;
h2o_mem_link_shared(pool, ctx->_timestamp_cache.value);
ts->str = ctx->_timestamp_cache.value;
}
h2o_timestamp_t ts;
ts.at = ctx->_timestamp_cache.tv_at;
h2o_mem_link_shared(pool, ctx->_timestamp_cache.value);
ts.str = ctx->_timestamp_cache.value;

return &ctx->_timestamp_cache.tv_at;
return ts;
}

inline void *h2o_context_get_handler_context(h2o_context_t *ctx, h2o_handler_t *handler)
Expand Down
5 changes: 2 additions & 3 deletions lib/core/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ h2o_hostconf_t *h2o_req_setup(h2o_req_t *req)
h2o_context_t *ctx = req->conn->ctx;
h2o_hostconf_t *hostconf;

h2o_get_timestamp(ctx, &req->pool, &req->processed_at);
req->processed_at = h2o_get_timestamp(ctx, &req->pool);

/* find the host context */
if (req->input.authority.base != NULL) {
Expand Down Expand Up @@ -732,7 +732,6 @@ h2o_iovec_t h2o_push_path_in_link_header(h2o_req_t *req, const char *value, size

void h2o_resp_add_date_header(h2o_req_t *req)
{
h2o_timestamp_t ts;
h2o_get_timestamp(req->conn->ctx, &req->pool, &ts);
h2o_timestamp_t ts = h2o_get_timestamp(req->conn->ctx, &req->pool);
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_DATE, NULL, ts.str->rfc1123, strlen(ts.str->rfc1123));
}

0 comments on commit ca48f3b

Please sign in to comment.