} ngx_js_dict_entry_t;
+static ngx_inline ngx_uint_t
+ngx_js_dict_expired(ngx_msec_t expire, ngx_msec_t now)
+{
+ return (ngx_msec_int_t) (now - expire) >= 0;
+}
+
+
static njs_int_t njs_js_ext_shared_dict_capacity(njs_vm_t *vm,
njs_object_prop_t *prop, uint32_t unused, njs_value_t *value,
njs_value_t *setval, njs_value_t *retval);
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now >= node->expire.key) {
+ if (ngx_js_dict_expired(node->expire.key, now)) {
node = NULL;
}
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now < node->expire.key) {
+ if (!ngx_js_dict_expired(node->expire.key, now)) {
njs_value_number_set(retval,
(double) (node->expire.key - now));
ngx_rwlock_unlock(&dict->sh->rwlock);
node = ngx_js_dict_lookup(dict, key);
- if (node != NULL && dict->timeout && now >= node->expire.key) {
+ if (node != NULL && dict->timeout
+ && ngx_js_dict_expired(node->expire.key, now))
+ {
ngx_js_dict_expire_unlink(dict, node);
ngx_rbtree_delete(&dict->sh->rbtree, &node->sn.node);
ngx_js_dict_node_free(dict, node);
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now >= node->expire.key) {
+ if (ngx_js_dict_expired(node->expire.key, now)) {
goto not_found;
}
}
rn != NULL;
rn = next)
{
- if (rn->key > now) {
+ if (!ngx_js_dict_expired(rn->key, now)) {
return;
}
next = ngx_rbtree_next(rbtree, rn);
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
if (dict->timeout) {
expire = entries[i].expire;
- if (expire && now >= expire) {
+ if (expire && ngx_js_dict_expired(expire, now)) {
dict->write_id = dict->sh->write_id;
continue;
}
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now >= node->expire.key) {
+ if (ngx_js_dict_expired(node->expire.key, now)) {
node = NULL;
}
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
{
node = (ngx_js_dict_node_t *) rn;
- if (dict->timeout && now >= node->expire.key) {
+ if (dict->timeout && ngx_js_dict_expired(node->expire.key, now)) {
continue;
}
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now < node->expire.key) {
+ if (!ngx_js_dict_expired(node->expire.key, now)) {
ngx_rwlock_unlock(&dict->sh->rwlock);
JS_FreeCString(cx, (char *) key.data);
return JS_NewFloat64(cx, (double) (node->expire.key - now));
tp = ngx_timeofday();
now = tp->sec * 1000 + tp->msec;
- if (now >= node->expire.key) {
+ if (ngx_js_dict_expired(node->expire.key, now)) {
goto not_found;
}
}