Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/ngx_http_lua_shdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -2623,11 +2623,12 @@ ngx_http_lua_ffi_shdict_get(ngx_shm_zone_t *zone, u_char *key,
int
ngx_http_lua_ffi_shdict_incr(ngx_shm_zone_t *zone, u_char *key,
size_t key_len, double *value, char **err, int has_init, double init,
int *forcible)
long init_ttl, int *forcible)
{
int i, n;
uint32_t hash;
ngx_int_t rc;
ngx_time_t *tp = NULL;
ngx_http_lua_shdict_ctx_t *ctx;
ngx_http_lua_shdict_node_t *sd;
double num;
Expand All @@ -2639,6 +2640,10 @@ ngx_http_lua_ffi_shdict_incr(ngx_shm_zone_t *zone, u_char *key,
return NGX_ERROR;
}

if (init_ttl > 0) {
tp = ngx_timeofday();
}

ctx = zone->data;

*forcible = 0;
Expand Down Expand Up @@ -2802,7 +2807,13 @@ ngx_http_lua_ffi_shdict_incr(ngx_shm_zone_t *zone, u_char *key,

sd->user_flags = 0;

sd->expires = 0;
if (init_ttl > 0) {
sd->expires = (uint64_t) tp->sec * 1000 + tp->msec
+ (uint64_t) init_ttl;

} else {
sd->expires = 0;
}

dd("setting value type to %d", LUA_TNUMBER);

Expand Down