#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
static struct hash_slinger *hash;
+static double
+HSH_Grace(double g)
+{
+ if (isnan(g))
+ return (double)(params->default_grace);
+ return (g);
+}
+
/* Precreate an objhead and object for later use */
void
HSH_Prealloc(struct sess *sp)
w->nobj->http->magic = HTTP_MAGIC;
w->nobj->busy = 1;
w->nobj->refcnt = 1;
+ w->nobj->grace = NAN;
VTAILQ_INIT(&w->nobj->store);
VTAILQ_INIT(&w->nobj->esibits);
VSL_stats->n_object++;
break;
/* Remember any matching objects inside their grace period */
- if (o->ttl + o->grace >= sp->t_req)
+ if (o->ttl + HSH_Grace(o->grace) >= sp->t_req)
grace_o = o;
}
*/
if (o == NULL && grace_o != NULL &&
grace_o->child != NULL &&
- grace_o->ttl + sp->grace >= sp->t_req)
+ grace_o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
o = grace_o;
if (o != NULL) {
#include <arpa/inet.h>
#include <stdio.h>
+#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
+ if (isnan(sp->obj->grace))
+ return ((double)params->default_grace);
return (sp->obj->grace);
}
VRT_r_req_grace(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ if (isnan(sp->grace))
+ return ((double)params->default_grace);
return (sp->grace);
}
"\n"
"Minimum is 1 second.",
EXPERIMENTAL | DELAYED_EFFECT,
- "120", "seconds" },
+ "300", "seconds" },
{ "thread_pool_purge_delay",
tweak_timeout, &master.wthread_purge_delay, 100, 0,
"Wait this long between purging threads.\n"
"Setting this too short increases the risk of worker "
"thread pile-up.\n",
EXPERIMENTAL,
- "10", "milliseconds" },
+ "20", "milliseconds" },
{ "thread_pool_fail_delay",
tweak_timeout, &master.wthread_fail_delay, 100, UINT_MAX,
"Wait at least this long after a failed thread creation "
"Minimum is 1024 bytes.",
DELAYED_EFFECT,
"8192", "bytes" },
+ { "default_grace", tweak_uint, &master.default_grace, 0, UINT_MAX,
+ "Default grace period. We will deliver an object "
+ "this long after it has expired, provided another thread "
+ "is attempting to get a new copy.",
+ DELAYED_EFFECT,
+ "10" "seconds" },
{ "sess_timeout", tweak_timeout, &master.sess_timeout, 0, 0,
"Idle timeout for persistent sessions. "
"If a HTTP request has not been received in this many "