commit - 1962764c6292e845cec17393e1c46c1473ca1eeb
commit + 5d22294a59e7e9cbe6457b9e6244fff2ede09956
blob - 3eaff8416924b089325ab0d9409af849c1c2fd90
blob + a034a275edc32373952e64f67b8064f98def684b
--- config.c
+++ config.c
TAILQ_INIT(&hosts);
+ TAILQ_INIT(&conf.fcgi);
+
conf.port = 1965;
conf.ipv6 = 0;
conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
config_free(void)
{
struct privsep *ps;
+ struct fcgi *f, *tf;
struct vhost *h, *th;
struct location *l, *tl;
struct proxy *p, *tp;
}
free_mime(&conf.mime);
+ TAILQ_FOREACH_SAFE(f, &conf.fcgi, fcgi, tf) {
+ TAILQ_REMOVE(&conf.fcgi, f, fcgi);
+ free(f);
+ }
memset(&conf, 0, sizeof(conf));
conf.ps = ps;
conf.sock4 = conf.sock6 = -1;
conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
init_mime(&conf.mime);
+ TAILQ_INIT(&conf.fcgi);
TAILQ_FOREACH_SAFE(h, &hosts, vhosts, th) {
free(h->cert_path);
TAILQ_REMOVE(&hosts, h, vhosts);
free(h);
}
-
- memset(fcgi, 0, sizeof(fcgi));
}
static int
}
int
-config_send(struct conf *conf, struct fcgi *fcgi, struct vhosthead *hosts)
+config_send(struct conf *conf, struct vhosthead *hosts)
{
struct privsep *ps = conf->ps;
struct etm *m;
+ struct fcgi *fcgi;
struct vhost *h;
struct location *l;
struct proxy *p;
if (proc_flush_imsg(ps, PROC_SERVER, -1) == -1)
return -1;
- for (i = 0; i < FCGI_MAX; ++i) {
- if (*fcgi[i].path == '\0')
- break;
+ TAILQ_FOREACH(fcgi, &conf->fcgi, fcgi) {
+ log_debug("sending fastcgi %s", fcgi->path);
if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_FCGI,
- &fcgi[i], sizeof(fcgi[i])) == -1)
+ fcgi, sizeof(*fcgi)) == -1)
return -1;
}
static struct proxy *p;
struct privsep *ps = conf->ps;
struct etm m;
- struct fcgi *f;
+ struct fcgi *fcgi;
struct vhost *vh, vht;
struct location *loc;
struct envlist *env;
struct alist *alias;
struct proxy *proxy;
- size_t i, datalen;
+ size_t datalen;
datalen = IMSG_DATA_SIZE(imsg);
break;
case IMSG_RECONF_FCGI:
- for (i = 0; i < FCGI_MAX; ++i) {
- f = &fcgi[i];
- if (*f->path != '\0')
- continue;
- IMSG_SIZE_CHECK(imsg, f);
- memcpy(f, imsg->data, datalen);
- break;
- }
- if (i == FCGI_MAX)
- fatalx("recv too many fcgi");
+ IMSG_SIZE_CHECK(imsg, fcgi);
+ fcgi = xcalloc(1, sizeof(*fcgi));
+ memcpy(fcgi, imsg->data, datalen);
+ log_debug("received fcgi %s", fcgi->path);
+ TAILQ_INSERT_TAIL(&conf->fcgi, fcgi, fcgi);
break;
case IMSG_RECONF_HOST:
blob - 825067a9ebcd288fe81d1e139a3219361a3b4f1d
blob + 63065aa618e8a098ed498501d0cd387ca342ec1b
--- ge.c
+++ ge.c
struct conf conf;
int privsep_process;
-struct fcgi fcgi[FCGI_MAX]; /* just because it's referenced */
struct vhosthead hosts = TAILQ_HEAD_INITIALIZER(hosts);
static const struct option opts[] = {
blob - a03ccbb5eabc4dacafbf28642cac2d1929ace78f
blob + 11aaec404f67102274e360377ac50b0f7323fbc1
--- gmid.c
+++ gmid.c
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
-
-struct fcgi fcgi[FCGI_MAX];
struct vhosthead hosts;
if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_START, NULL, 0) == -1)
return -1;
- if (config_send(conf, fcgi, &hosts) == -1)
+ if (config_send(conf, &hosts) == -1)
return -1;
if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_END, NULL, 0) == -1)
blob - db7f8cbe59724d03a7dedb62fe5254b2424e3ab2
blob + fc64880a13d8d8fb58c39b15f18c7ee6fa17fc94
--- gmid.h
+++ gmid.h
#define FCGI_NAME_MAX 511
#define FCGI_VAL_MAX 511
-#define FCGI_MAX 32
#define PROC_MAX_INSTANCES 16
/* forward declaration */
const char *err;
};
+TAILQ_HEAD(fcgihead, fcgi);
struct fcgi {
int id;
char path[PATH_MAX];
char port[32];
+ TAILQ_ENTRY(fcgi) fcgi;
};
-extern struct fcgi fcgi[FCGI_MAX];
TAILQ_HEAD(proxyhead, proxy);
struct proxy {
struct event evsock4;
int sock6;
struct event evsock6;
+
+ struct fcgihead fcgi;
};
extern const char *config_path;
/* config.c */
void config_init(void);
void config_free(void);
-int config_send(struct conf *, struct fcgi *, struct vhosthead *);
+int config_send(struct conf *, struct vhosthead *);
int config_recv(struct conf *, struct imsg *);
/* parse.y */
blob - 7209d7b1803788efb43f61057e45ca9f8c2d288f
blob + fb88fcac5af5df99b46d30ed604da028ecb28065
--- parse.y
+++ parse.y
fastcgi_conf(const char *path, const char *port)
{
struct fcgi *f;
- int i;
-
- for (i = 0; i < FCGI_MAX; ++i) {
- f = &fcgi[i];
+ int i = 0;
- if (*f->path == '\0') {
- f->id = i;
- (void) strlcpy(f->path, path, sizeof(f->path));
- if (port != NULL)
- (void) strlcpy(f->port, port, sizeof(f->port));
- return i;
- }
-
+ TAILQ_FOREACH(f, &conf.fcgi, fcgi) {
if (!strcmp(f->path, path) &&
((port == NULL && *f->port == '\0') ||
!strcmp(f->port, port)))
return i;
+ ++i;
}
- yyerror("too much `fastcgi' rules defined.");
- return -1;
+ f = xcalloc(1, sizeof(*f));
+ f->id = i;
+ (void)strlcpy(f->path, path, sizeof(f->path));
+ if (port != NULL)
+ (void)strlcpy(f->port, port, sizeof(f->port));
+ TAILQ_INSERT_TAIL(&conf.fcgi, f, fcgi);
+
+ return f->id;
}
void
blob - 6b7422cd0a0ae8a6abe67ff8adb11eba25d0c351
blob + 80f8d25cfb68c2b6d2cab4e4cc8031d3b955052e
--- server.c
+++ server.c
static int
apply_fastcgi(struct client *c)
{
- int id;
+ int id, i = 0;
struct fcgi *f;
if ((id = vhost_fastcgi(c->host, c->iri.path)) == -1)
return 0;
- f = &fcgi[id];
+ TAILQ_FOREACH(f, &conf.fcgi, fcgi) {
+ if (i == id)
+ break;
+ ++i;
+ }
+
+ if (f == NULL) {
+ log_warnx("can't find fcgi #%d", id);
+ return 0;
+ }
log_debug("opening fastcgi connection for (%s,%s)",
f->path, f->port);