Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P6178
admissionprob.c
Active
Public
Actions
Authored by
•
ema
on Oct 25 2017, 10:18 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F10426450: admissionprob.c
Oct 25 2017, 10:18 AM
2017-10-25 10:18:13 (UTC+0)
Subscribers
None
if
(
beresp
.
status
==
200
&&
bereq
.
http
.
X
-
CDIS
==
"miss"
)
{
C
{
const
struct
gethdr_s
prob_hdr
=
{
HDR_BERESP
,
"
\030
X-Admission-Probability:"
};
const
struct
gethdr_s
urand_hdr
=
{
HDR_BERESP
,
"
\022
X-Admission-Urand:"
};
const
struct
gethdr_s
hdr
=
{
HDR_BERESP
,
"
\017
Content-Length:"
};
const
char
*
clen_hdr
=
VRT_GetHdr
(
ctx
,
&
hdr
);
const
double
urand
=
drand48
();
double
admissionprob
;
// Set CL:0 by default
int
clen
=
0
;
// If Content-Length has been specified
if
(
clen_hdr
)
clen
=
atoi
(
clen_hdr
);
admissionprob
=
exp
(
-
clen
/
adm_param
);
VRT_SetHdr
(
ctx
,
&
prob_hdr
,
VRT_REAL_string
(
ctx
,
admissionprob
),
vrt_magic_string_end
);
VRT_SetHdr
(
ctx
,
&
urand_hdr
,
VRT_REAL_string
(
ctx
,
urand
),
vrt_magic_string_end
);
// If admission test succeeds, mark as uncacheable (set ttl=0, do not
// create hit-for-pass)
if
(
admissionprob
<
urand
)
{
VRT_l_beresp_ttl
(
ctx
,
0
);
VRT_l_beresp_uncacheable
(
ctx
,
1
);
}
}
C
}
Event Timeline
•
ema
created this paste.
Oct 25 2017, 10:18 AM
2017-10-25 10:18:13 (UTC+0)
Esc3300
mentioned this in
T287732: Allow filtering property searches by datatype
.
Sep 7 2021, 6:03 PM
2021-09-07 18:03:09 (UTC+0)
Log In to Comment