CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
-/* Update health ----------------------------------------------*/
-
+/* Update health ----------------------------------------------------*/
+/* See cache_backend_random.c and/or cache_backend_round_robin.c for
+ * details and comments about this function.
+ */
void
VBE_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
{
struct backend *b;
- CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
- CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
- b = vc->backend;
+ if (vc != NULL) {
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ b = vc->backend;
+ }
+ else {
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ b = sp->backend;
+ }
AN(b->method);
if(b->method->updatehealth != NULL)
b->method->updatehealth(sp, vc, a);
/*--------------------------------------------------------------------*/
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
static void
ber_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
{
/*--------------------------------------------------------------------*/
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
static void
brr_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
{