extern struct evbase *mgt_evb;
/* mgt_child.c */
-void mgt_run(int dflag);
+void mgt_run(int dflag, const char *Tflag);
extern pid_t mgt_pid, child_pid;
/* mgt_cli.c */
int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...);
void mgt_cli_start_child(int fdi, int fdo);
void mgt_cli_stop_child(void);
+int mgt_cli_telnet(const char *port);
/* mgt_vcc.c */
void mgt_vcc_init(void);
int mgt_push_vcls_and_start(unsigned *status, char **p);
/* tcp.c */
-int open_tcp(const char *port);
+int open_tcp(const char *port, int http);
#include "stevedore.h"
*/
void
-mgt_run(int dflag)
+mgt_run(int dflag, const char *Tflag)
{
struct sigaction sac;
struct ev *e;
if (dflag)
mgt_cli_setup(0, 1, 1);
+ if (Tflag)
+ mgt_cli_telnet(Tflag);
+
e = ev_new();
assert(e != NULL);
e->sig = SIGTERM;
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/socket.h>
#ifndef HAVE_VASPRINTF
#include "compat/vasprintf.h"
#include "shmlog.h"
static int cli_i = -1, cli_o = -1;
+static int telnet_sock;
+static struct ev *telnet_ev;
/*--------------------------------------------------------------------*/
struct cli_proto *cp;
unsigned u, v;
-
/*
* Build the joint cli_proto by combining the manager process
* entries with with the cache process entries. The latter
/* Fixup the entry for 'help' entry */
assert(!strcmp(cli_proto[0].request, "help"));
cli_proto[0].priv = cli_proto;
-
- /* XXX: open listening sockets, contact cluster server etc */
}
/*--------------------------------------------------------------------
cp->ev->priv = cp;
ev_add(mgt_evb, cp->ev);
}
+
+static int
+telnet_accept(struct ev *ev, int what)
+{
+ socklen_t l;
+ struct sockaddr addr[2]; /* XXX IPv6 hack */
+ int i;
+
+ (void)ev;
+ (void)what;
+ l = sizeof addr;
+ i = accept(telnet_sock, addr, &l);
+ if (i < 0)
+ return (0);
+
+ mgt_cli_setup(i, i, 0);
+ return (0);
+}
+
+int
+mgt_cli_telnet(const char *port)
+{
+
+ telnet_sock = open_tcp(port, 0);
+ if (telnet_sock < 0) {
+ fprintf(stderr, "Could not open TELNET port\n");
+ exit (2);
+ }
+ telnet_ev = ev_new();
+ assert(telnet_ev != NULL);
+ telnet_ev->fd = telnet_sock;
+ telnet_ev->fd_flags = POLLIN;
+ telnet_ev->callback = telnet_accept;
+ ev_add(mgt_evb, telnet_ev);
+ return (0);
+}
#ifndef HAVE_STRLCPY
#include "compat/strlcpy.h"
#endif
-#include "heritage.h"
#include "mgt.h"
/*--------------------------------------------------------------------*/
}
int
-open_tcp(const char *port)
+open_tcp(const char *port, int http)
{
int sd, val;
struct addrinfo *res;
return (-1);
}
#ifdef HAVE_ACCEPT_FILTERS
- accept_filter(sd);
+ if (http)
+ accept_filter(sd);
+#else
+ (void)http;
#endif
freeaddrinfo(res);
- heritage.socket = sd;
- return (0);
+ return (sd);
}
fprintf(stderr, " %-28s # %s\n", "",
" -s file,<dir_or_file>,<size>");
fprintf(stderr, " %-28s # %s\n", "-t", "Default TTL");
+ fprintf(stderr, " %-28s # %s\n", "-T port", "Telnet port");
fprintf(stderr, " %-28s # %s\n", "-V", "version");
fprintf(stderr, " %-28s # %s\n", "-w int[,int[,int]]",
"Number of worker threads");
#if 0
-c clusterid@cluster_controller
-m memory_limit
- -s kind[,storage-options]
-l logfile,logsize
-u uid
-a CLI_port
const char *fflag = NULL;
const char *sflag = "file";
const char *hflag = "classic";
+ const char *Tflag = NULL;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
heritage.wthread_timeout = 10;
heritage.mem_workspace = 4096;
- while ((o = getopt(argc, argv, "b:df:h:p:s:t:Vw:")) != -1)
+ while ((o = getopt(argc, argv, "b:df:h:p:s:t:T:Vw:")) != -1)
switch (o) {
case 'b':
bflag = optarg;
case 't':
heritage.default_ttl = strtoul(optarg, NULL, 0);
break;
+ case 'T':
+ Tflag = optarg;
+ break;
case 'V':
varnish_version("varnishd");
exit(0);
* but do not answer. That, on the other hand, would eliminate the
* possibility of doing a "no-glitch" restart of the child process.
*/
- if (open_tcp(portnumber))
+ heritage.socket = open_tcp(portnumber, 1);
+ if (heritage.socket < 0)
exit (2);
VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024);
mgt_cli_init();
- mgt_run(dflag);
+ mgt_run(dflag, Tflag);
exit(0);
}