Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
16c8251d
Commit
16c8251d
authored
Mar 07, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass the vmod.object::init function the VCL name of the object being
created. Split the demo-rr director into its own file
parent
011944d3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
125 additions
and
87 deletions
+125
-87
vcc_action.c
lib/libvcl/vcc_action.c
+1
-1
vmodtool.py
lib/libvcl/vmodtool.py
+1
-1
Makefile.am
lib/libvmod_debug/Makefile.am
+2
-1
vmod_debug_obj.c
lib/libvmod_debug/vmod_debug_obj.c
+3
-84
vmod_debug_rr.c
lib/libvmod_debug/vmod_debug_rr.c
+118
-0
No files found.
lib/libvcl/vcc_action.c
View file @
16c8251d
...
...
@@ -220,7 +220,7 @@ parse_new(struct vcc *tl)
vcc_NextToken
(
tl
);
bprintf
(
buf1
,
", &%s
"
,
sy1
->
name
);
bprintf
(
buf1
,
", &%s
,
\"
%s
\"
"
,
sy1
->
name
,
sy1
->
name
);
vcc_Eval_Func
(
tl
,
s_init
,
buf1
,
"ASDF"
,
s_init
+
strlen
(
s_init
)
+
1
);
Ff
(
tl
,
0
,
"
\t
%s((struct req*)0, &%s);
\n
"
,
s_fini
,
sy1
->
name
);
ExpectErr
(
tl
,
';'
);
...
...
lib/libvcl/vmodtool.py
View file @
16c8251d
...
...
@@ -300,7 +300,7 @@ class obj(object):
def
set_modnam
(
self
,
modnam
):
self
.
st
=
"struct vmod_"
+
modnam
+
"_"
+
self
.
nam
self
.
init
.
set_pfx
(
", "
+
self
.
st
+
" **"
)
self
.
init
.
set_pfx
(
", "
+
self
.
st
+
" **
, const char *
"
)
self
.
fini
.
set_pfx
(
", "
+
self
.
st
+
" **"
)
for
m
in
self
.
methods
:
m
.
set_pfx
(
", "
+
self
.
st
+
" *"
)
...
...
lib/libvmod_debug/Makefile.am
View file @
16c8251d
...
...
@@ -15,7 +15,8 @@ libvmod_debug_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version
libvmod_debug_la_SOURCES
=
\
vmod_debug.c
\
vmod_debug_obj.c
vmod_debug_obj.c
\
vmod_debug_rr.c
nodist_libvmod_debug_la_SOURCES
=
\
vcc_if.c
\
...
...
lib/libvmod_debug/vmod_debug_obj.c
View file @
16c8251d
...
...
@@ -42,11 +42,13 @@ struct vmod_debug_obj {
};
VCL_VOID
vmod_obj__init
(
struct
req
*
req
,
struct
vmod_debug_obj
**
op
,
VCL_STRING
s
)
vmod_obj__init
(
struct
req
*
req
,
struct
vmod_debug_obj
**
op
,
const
char
*
vcl_name
,
VCL_STRING
s
)
{
struct
vmod_debug_obj
*
o
;
(
void
)
req
;
(
void
)
vcl_name
;
(
void
)
s
;
AN
(
op
);
AZ
(
*
op
);
...
...
@@ -86,86 +88,3 @@ vmod_obj_date(struct req *req, struct vmod_debug_obj *o)
assert
(
o
->
foobar
==
42
);
return
(
21
.
4
);
}
/*----------------------------------------------------------------------*/
struct
vmod_debug_rr_entry
{
unsigned
magic
;
#define VMOD_DEBUG_RR_ENTRY_MAGIC 0xa80970cf
VTAILQ_ENTRY
(
vmod_debug_rr_entry
)
list
;
VCL_BACKEND
be
;
};
struct
vmod_debug_rr
{
unsigned
magic
;
#define VMOD_DEBUG_RR_MAGIC 0x99f4b726
VTAILQ_HEAD
(,
vmod_debug_rr_entry
)
listhead
;
pthread_mutex_t
mtx
;
};
VCL_VOID
vmod_rr__init
(
struct
req
*
req
,
struct
vmod_debug_rr
**
rrp
)
{
struct
vmod_debug_rr
*
rr
;
(
void
)
req
;
AN
(
rrp
);
AZ
(
*
rrp
);
ALLOC_OBJ
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AN
(
rr
);
*
rrp
=
rr
;
AZ
(
pthread_mutex_init
(
&
rr
->
mtx
,
NULL
));
VTAILQ_INIT
(
&
rr
->
listhead
);
}
VCL_VOID
vmod_rr__fini
(
struct
req
*
req
,
struct
vmod_debug_rr
**
rrp
)
{
struct
vmod_debug_rr
*
rr
;
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
rr
=
*
rrp
;
*
rrp
=
NULL
;
CHECK_OBJ_NOTNULL
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AZ
(
pthread_mutex_destroy
(
&
rr
->
mtx
));
while
(
!
VTAILQ_EMPTY
(
&
rr
->
listhead
))
{
ep
=
VTAILQ_FIRST
(
&
rr
->
listhead
);
VTAILQ_REMOVE
(
&
rr
->
listhead
,
ep
,
list
);
FREE_OBJ
(
ep
);
}
FREE_OBJ
(
*
rrp
);
}
VCL_VOID
vmod_rr_add_backend
(
struct
req
*
req
,
struct
vmod_debug_rr
*
rr
,
VCL_BACKEND
be
)
{
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
ALLOC_OBJ
(
ep
,
VMOD_DEBUG_RR_ENTRY_MAGIC
);
AN
(
ep
);
ep
->
be
=
be
;
AZ
(
pthread_mutex_lock
(
&
rr
->
mtx
));
VTAILQ_INSERT_TAIL
(
&
rr
->
listhead
,
ep
,
list
);
AZ
(
pthread_mutex_unlock
(
&
rr
->
mtx
));
}
VCL_BACKEND
vmod_rr_select
(
struct
req
*
req
,
struct
vmod_debug_rr
*
rr
)
{
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
CHECK_OBJ_NOTNULL
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
rr
->
mtx
));
ep
=
VTAILQ_FIRST
(
&
rr
->
listhead
);
VTAILQ_REMOVE
(
&
rr
->
listhead
,
ep
,
list
);
VTAILQ_INSERT_TAIL
(
&
rr
->
listhead
,
ep
,
list
);
AZ
(
pthread_mutex_unlock
(
&
rr
->
mtx
));
return
(
ep
->
be
);
}
lib/libvmod_debug/vmod_debug_rr.c
0 → 100644
View file @
16c8251d
/*-
* Copyright (c) 2013 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include <stdlib.h>
#include "cache/cache.h"
#include "vrt.h"
#include "vcc_if.h"
struct
vmod_debug_rr_entry
{
unsigned
magic
;
#define VMOD_DEBUG_RR_ENTRY_MAGIC 0xa80970cf
VTAILQ_ENTRY
(
vmod_debug_rr_entry
)
list
;
VCL_BACKEND
be
;
};
struct
vmod_debug_rr
{
unsigned
magic
;
#define VMOD_DEBUG_RR_MAGIC 0x99f4b726
VTAILQ_HEAD
(,
vmod_debug_rr_entry
)
listhead
;
pthread_mutex_t
mtx
;
};
VCL_VOID
vmod_rr__init
(
struct
req
*
req
,
struct
vmod_debug_rr
**
rrp
,
const
char
*
vcl_name
)
{
struct
vmod_debug_rr
*
rr
;
(
void
)
req
;
(
void
)
vcl_name
;
AN
(
rrp
);
AZ
(
*
rrp
);
ALLOC_OBJ
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AN
(
rr
);
*
rrp
=
rr
;
AZ
(
pthread_mutex_init
(
&
rr
->
mtx
,
NULL
));
VTAILQ_INIT
(
&
rr
->
listhead
);
}
VCL_VOID
vmod_rr__fini
(
struct
req
*
req
,
struct
vmod_debug_rr
**
rrp
)
{
struct
vmod_debug_rr
*
rr
;
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
rr
=
*
rrp
;
*
rrp
=
NULL
;
CHECK_OBJ_NOTNULL
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AZ
(
pthread_mutex_destroy
(
&
rr
->
mtx
));
while
(
!
VTAILQ_EMPTY
(
&
rr
->
listhead
))
{
ep
=
VTAILQ_FIRST
(
&
rr
->
listhead
);
VTAILQ_REMOVE
(
&
rr
->
listhead
,
ep
,
list
);
FREE_OBJ
(
ep
);
}
FREE_OBJ
(
*
rrp
);
}
VCL_VOID
vmod_rr_add_backend
(
struct
req
*
req
,
struct
vmod_debug_rr
*
rr
,
VCL_BACKEND
be
)
{
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
ALLOC_OBJ
(
ep
,
VMOD_DEBUG_RR_ENTRY_MAGIC
);
AN
(
ep
);
ep
->
be
=
be
;
AZ
(
pthread_mutex_lock
(
&
rr
->
mtx
));
VTAILQ_INSERT_TAIL
(
&
rr
->
listhead
,
ep
,
list
);
AZ
(
pthread_mutex_unlock
(
&
rr
->
mtx
));
}
VCL_BACKEND
vmod_rr_select
(
struct
req
*
req
,
struct
vmod_debug_rr
*
rr
)
{
struct
vmod_debug_rr_entry
*
ep
;
(
void
)
req
;
CHECK_OBJ_NOTNULL
(
rr
,
VMOD_DEBUG_RR_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
rr
->
mtx
));
ep
=
VTAILQ_FIRST
(
&
rr
->
listhead
);
VTAILQ_REMOVE
(
&
rr
->
listhead
,
ep
,
list
);
VTAILQ_INSERT_TAIL
(
&
rr
->
listhead
,
ep
,
list
);
AZ
(
pthread_mutex_unlock
(
&
rr
->
mtx
));
return
(
ep
->
be
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment