root/trunk/varnish-cache/bin/varnishd/cache_main.c @ 4929

Revision 4929, 3.2 KB (checked in by phk, 3 months ago)

Split and rename shmlog.h to vsl.h and vsc.h

  • Property svn:keywords set to Id
RevLine 
[1082]1/*-
2 * Copyright (c) 2006 Verdens Gang AS
[4025]3 * Copyright (c) 2006-2009 Linpro AS
[1082]4 * All rights reserved.
5 *
[1091]6 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
7 *
[1082]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 *
[1481]17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
[1082]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.
[56]28 */
29
[2455]30#include "config.h"
31
[4093]32#include "svnid.h"
33SVNID("$Id$")
34
[56]35#include <stdio.h>
[59]36#include <unistd.h>
[57]37#include <stdlib.h>
[159]38#include <signal.h>
[56]39
[61]40#include "cache.h"
[1732]41#include "stevedore.h"
[3405]42#include "hash_slinger.h"
[56]43
[298]44/*--------------------------------------------------------------------
[2969]45 * Per thread storage for the session currently being processed by
46 * the thread.  This is used for panic messages.
47 */
48
49static pthread_key_t sp_key;
50
51void
52THR_SetSession(const struct sess *sp)
53{
54
55        AZ(pthread_setspecific(sp_key, sp));
56}
57
58const struct sess *
59THR_GetSession(void)
60{
61
62        return (pthread_getspecific(sp_key));
63}
64
65/*--------------------------------------------------------------------
[2293]66 * Name threads if our pthreads implementation supports it.
67 */
68
[2972]69static pthread_key_t name_key;
70
[2293]71void
[2972]72THR_SetName(const char *name)
[2293]73{
[2972]74
75        AZ(pthread_setspecific(name_key, name));
[2293]76#ifdef HAVE_PTHREAD_SET_NAME_NP
77        pthread_set_name_np(pthread_self(), name);
78#endif
79}
80
[2972]81const char *
82THR_GetName(void)
83{
84
85        return (pthread_getspecific(name_key));
86}
87
[2293]88/*--------------------------------------------------------------------
[298]89 * XXX: Think more about which order we start things
90 */
[61]91
[56]92void
93child_main(void)
94{
[1732]95
[56]96        setbuf(stdout, NULL);
97        setbuf(stderr, NULL);
98        printf("Child starts\n");
99
[2969]100        AZ(pthread_key_create(&sp_key, NULL));
[2972]101        AZ(pthread_key_create(&name_key, NULL));
[2969]102
[2972]103        THR_SetName("cache-main");
[2293]104
[3381]105        VSL_Init();     /* First, LCK needs it. */
106
107        LCK_Init();     /* Locking, must be first */
108
[2971]109        PAN_Init();
[2598]110        CLI_Init();
[2836]111        Fetch_Init();
[2598]112
[932]113        CNT_Init();
[460]114        VCL_Init();
115
[531]116        HTTP_Init();
[467]117        SES_Init();
118
[86]119        VBE_Init();
[3084]120        VBP_Init();
[409]121        WRK_Init();
[62]122
[221]123        EXP_Init();
[233]124        HSH_Init();
[268]125        BAN_Init();
[61]126
[2598]127        VCA_Init();
128
[3025]129        SMS_Init();
[1730]130        STV_open();
[1732]131
[3939]132        BAN_Compile();
133
[3919]134        /* Wait for persistent storage to load if asked to */
135        if (params->diag_bitmap & 0x00020000)
136                SMP_Ready();
137
[2598]138        CLI_Run();
[615]139
[3897]140        STV_close();
141
[56]142        printf("Child dies\n");
143}
Note: See TracBrowser for help on using the browser.