Commit 88c1f30c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

If the first char of the serve string is '!', close connection after

sending string.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@440 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a03daf4f
...@@ -41,6 +41,7 @@ static struct bufferevent *e_racc; ...@@ -41,6 +41,7 @@ static struct bufferevent *e_racc;
struct serv { struct serv {
TAILQ_ENTRY(serv) list; TAILQ_ENTRY(serv) list;
char *data; char *data;
int close;
}; };
static TAILQ_HEAD(,serv) serv_head = TAILQ_HEAD_INITIALIZER(serv_head); static TAILQ_HEAD(,serv) serv_head = TAILQ_HEAD_INITIALIZER(serv_head);
...@@ -57,11 +58,13 @@ rd_acc(struct bufferevent *bev, void *arg) ...@@ -57,11 +58,13 @@ rd_acc(struct bufferevent *bev, void *arg)
p = evbuffer_readline(bev->input); p = evbuffer_readline(bev->input);
if (p == NULL) if (p == NULL)
return; return;
printf("A: <<%s>>\n", p); printf("B: <<%s>>\n", p);
if (*p == '\0') { if (*p == '\0') {
sp = TAILQ_FIRST(&serv_head); sp = TAILQ_FIRST(&serv_head);
assert(sp != NULL); assert(sp != NULL);
write(*ip, sp->data, strlen(sp->data)); write(*ip, sp->data, strlen(sp->data));
if (sp->close)
shutdown(*ip, SHUT_WR);
if (TAILQ_NEXT(sp, list) != NULL) { if (TAILQ_NEXT(sp, list) != NULL) {
TAILQ_REMOVE(&serv_head, sp, list); TAILQ_REMOVE(&serv_head, sp, list);
free(sp->data); free(sp->data);
...@@ -76,8 +79,8 @@ ex_acc(struct bufferevent *bev, short what, void *arg) ...@@ -76,8 +79,8 @@ ex_acc(struct bufferevent *bev, short what, void *arg)
{ {
int *ip; int *ip;
(void)what;
ip = arg; ip = arg;
printf("%s(%p, 0x%x, %p)\n", __func__, bev, what, arg);
bufferevent_disable(bev, EV_READ); bufferevent_disable(bev, EV_READ);
bufferevent_free(bev); bufferevent_free(bev);
close(*ip); close(*ip);
...@@ -170,7 +173,12 @@ cmd_serve(char **av) ...@@ -170,7 +173,12 @@ cmd_serve(char **av)
for (i = 0; av[i] != NULL; i++) { for (i = 0; av[i] != NULL; i++) {
sp = calloc(sizeof *sp, 1); sp = calloc(sizeof *sp, 1);
assert(sp != NULL); assert(sp != NULL);
sp->data = strdup(av[i]); if (av[i][0] == '!') {
sp->close = 1;
sp->data = strdup(av[i] + 1);
} else {
sp->data = strdup(av[i]);
}
assert(sp->data != NULL); assert(sp->data != NULL);
TAILQ_INSERT_TAIL(&serv_head, sp, list); TAILQ_INSERT_TAIL(&serv_head, sp, list);
} }
......
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