source: bin/varnishd/cache_main.c @ 8aa1d8

Revision 8aa1d8, 3.2 KB checked in by Poul-Henning Kamp <phk@…>, 3 years ago (diff)

Eliminate nested <*.h> includes from include/*

Sort #includes according to rules which are for me to know and you
to guess.

  • Property mode set to 100644
Line 
1/*-
2 * Copyright (c) 2006 Verdens Gang AS
3 * Copyright (c) 2006-2009 Varnish Software AS
4 * All rights reserved.
5 *
6 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include "config.h"
31
32#include <stdio.h>
33#include <stdlib.h>
34
35#include "cache.h"
36
37#include "cache_waiter.h"
38#include "hash_slinger.h"
39#include "stevedore.h"
40
41/*--------------------------------------------------------------------
42 * Per thread storage for the session currently being processed by
43 * the thread.  This is used for panic messages.
44 */
45
46static pthread_key_t sp_key;
47
48void
49THR_SetSession(const struct sess *sp)
50{
51
52        AZ(pthread_setspecific(sp_key, sp));
53}
54
55const struct sess *
56THR_GetSession(void)
57{
58
59        return (pthread_getspecific(sp_key));
60}
61
62/*--------------------------------------------------------------------
63 * Name threads if our pthreads implementation supports it.
64 */
65
66static pthread_key_t name_key;
67
68void
69THR_SetName(const char *name)
70{
71
72        AZ(pthread_setspecific(name_key, name));
73#ifdef HAVE_PTHREAD_SET_NAME_NP
74        pthread_set_name_np(pthread_self(), name);
75#endif
76}
77
78const char *
79THR_GetName(void)
80{
81
82        return (pthread_getspecific(name_key));
83}
84
85/*--------------------------------------------------------------------
86 * XXX: Think more about which order we start things
87 */
88
89void
90child_main(void)
91{
92
93        setbuf(stdout, NULL);
94        setbuf(stderr, NULL);
95        printf("Child starts\n");
96
97        AZ(pthread_key_create(&sp_key, NULL));
98        AZ(pthread_key_create(&name_key, NULL));
99
100        THR_SetName("cache-main");
101
102        VSL_Init();     /* First, LCK needs it. */
103
104        LCK_Init();     /* Second, locking */
105
106        WAIT_Init();
107        PAN_Init();
108        CLI_Init();
109        Fetch_Init();
110
111        CNT_Init();
112        VCL_Init();
113
114        HTTP_Init();
115
116        VBE_Init();
117        VBP_Init();
118        WRK_Init();
119        Pool_Init();
120
121        EXP_Init();
122        HSH_Init();
123        BAN_Init();
124
125        VCA_Init();
126
127        SMS_Init();
128        SMP_Init();
129        STV_open();
130
131        VMOD_Init();
132
133        BAN_Compile();
134
135        /* Wait for persistent storage to load if asked to */
136        if (params->diag_bitmap & 0x00020000)
137                SMP_Ready();
138
139        CLI_Run();
140
141        STV_close();
142
143        printf("Child dies\n");
144}
Note: See TracBrowser for help on using the repository browser.