Commit c012d86e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Cleanup VSUB_ and eliminate from libvarnish.h

parent 7ce0d474
......@@ -42,6 +42,7 @@
#include "libvcl.h"
#include "vcli.h"
#include "vsub.h"
#include "vcl.h"
#include "cli_priv.h"
#include "mgt_cli.h"
......@@ -238,7 +239,7 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag)
vp.magic = VCC_PRIV_MAGIC;
vp.sf = sf;
vp.vcl = vcl;
if (SUB_run(sb, run_vcc, &vp, "VCC-compiler", -1)) {
if (VSUB_run(sb, run_vcc, &vp, "VCC-compiler", -1)) {
(void)unlink(sf);
return (NULL);
}
......@@ -261,13 +262,13 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag)
cmdsb = mgt_make_cc_cmd(sf, of);
/* Run the C-compiler in a sub-shell */
i = SUB_run(sb, run_cc, VSB_data(cmdsb), "C-compiler", 10);
i = VSUB_run(sb, run_cc, VSB_data(cmdsb), "C-compiler", 10);
(void)unlink(sf);
VSB_delete(cmdsb);
if (!i)
i = SUB_run(sb, run_dlopen, of, "dlopen", 10);
i = VSUB_run(sb, run_dlopen, of, "dlopen", 10);
if (i) {
(void)unlink(of);
......
......@@ -54,6 +54,7 @@ nobase_noinst_HEADERS = \
vrt.h \
vrt_obj.h \
vsb.h \
vsub.h \
vsha256.h \
vss.h \
vtcp.h
......
......@@ -41,11 +41,6 @@ struct vsb;
/* from libvarnish/num.c */
const char *str2bytes(const char *p, uintmax_t *r, uintmax_t rel);
/* from libvarnish/subproc.c */
typedef void sub_func_f(void*);
int SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name,
int maxlines);
/* from libvarnish/time.c */
#define TIM_FORMAT_SIZE 30
void TIM_format(double t, char *p);
......
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* 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.
*
*/
/* from libvarnish/subproc.c */
typedef void vsub_func_f(void*);
int VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
int maxlines);
......@@ -8,7 +8,7 @@ libvarnish_la_SOURCES = \
vav.c \
vas.c \
binary_heap.c \
subproc.c \
vsub.c \
cli_auth.c \
cli_common.c \
cli_serve.c \
......
......@@ -38,11 +38,12 @@
#include <sys/wait.h>
#include "vsb.h"
#include "vas.h"
#include "vlu.h"
#include "libvarnish.h"
#include "vsb.h"
#include "vsub.h"
struct sub_priv {
struct vsub_priv {
const char *name;
struct vsb *sb;
int lines;
......@@ -50,9 +51,9 @@ struct sub_priv {
};
static int
sub_vlu(void *priv, const char *str)
vsub_vlu(void *priv, const char *str)
{
struct sub_priv *sp;
struct vsub_priv *sp;
sp = priv;
if (!sp->lines++)
......@@ -63,13 +64,13 @@ sub_vlu(void *priv, const char *str)
}
int
SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name,
VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
int maxlines)
{
int rv, p[2], sfd, status;
pid_t pid;
struct vlu *vlu;
struct sub_priv sp;
struct vsub_priv sp;
sp.sb = sb;
sp.name = name;
......@@ -102,7 +103,7 @@ SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name,
_exit(1);
}
AZ(close(p[1]));
vlu = VLU_New(&sp, sub_vlu, 0);
vlu = VLU_New(&sp, vsub_vlu, 0);
while (!VLU_Fd(p[0], vlu))
continue;
AZ(close(p[0]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment