Code Coverage: vinyl-cache/bin/vinyld/cache/cache_objhead.h
 
82217aa4fc7094b3610340078afaf78cd95a8ec9
 
0
/*-
1
 * Copyright (c) 2006 Verdens Gang AS
2
 * Copyright (c) 2006-2015 Varnish Software AS
3
 * All rights reserved.
4
 *
5
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
6
 *
7
 * SPDX-License-Identifier: BSD-2-Clause
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 * SUCH DAMAGE.
29
 *
30
 */
31
32
struct hash_slinger;
33
34
struct objhead {
35
        unsigned                magic;
36
#define OBJHEAD_MAGIC           0x1b96615d
37
38
        int                     refcnt;
39
        struct lock             mtx;
40
        VTAILQ_HEAD(,objcore)   objcs;
41
        uint8_t                 digest[DIGEST_LEN];
42
        unsigned                waitinglist_gen;
43
        VTAILQ_HEAD(, req)      waitinglist;
44
45
        /*----------------------------------------------------
46
         * The fields below are for the sole private use of
47
         * the hash implementation(s).
48
         */
49
        union {
50
                struct {
51
                        VTAILQ_ENTRY(objhead)   u_n_hoh_list;
52
                        void                    *u_n_hoh_head;
53
                } n;
54
        } _u;
55
#define hoh_list _u.n.u_n_hoh_list
56 2
#define hoh_head _u.n.u_n_hoh_head
57
};
58
59
enum lookup_e {
60
        HSH_MISS,
61
        HSH_HITMISS,
62
        HSH_HITPASS,
63
        HSH_HIT,
64
        HSH_GRACE,
65
        HSH_BUSY,
66
};
67
68
void HSH_Kill(struct objcore *);
69
void HSH_Replace(struct objcore *, const struct objcore *);
70
void HSH_Insert(struct worker *, const void *hash, struct objcore *,
71
    struct ban *);
72
void HSH_Withdraw(struct worker *, struct objcore **);
73
void HSH_Fail(struct worker *, struct objcore *);
74
void HSH_Unbusy(struct worker *, struct objcore *);
75
int HSH_Snipe(const struct worker *, struct objcore *);
76
struct boc *HSH_RefBoc(const struct objcore *);
77
void HSH_DerefBoc(struct worker *wrk, struct objcore *);
78
void HSH_DeleteObjHead(const struct worker *, struct objhead *);
79
int HSH_DerefObjCore(struct worker *, struct objcore **);
80
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **);
81
void HSH_Ref(struct objcore *o);
82
void HSH_AddString(struct req *, void *ctx, const char *str);
83
unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now,
84
    vtim_dur ttl, vtim_dur grace, vtim_dur keep);
85
struct objcore *HSH_Private(const struct worker *wrk);
86
void HSH_Cancel(struct worker *, struct objcore *, struct boc *);