commit - da30c05a101318828faf559ea66bc6ce1f638bc8
commit + 2a83fef7ce7879df1f318a442bb1d8d0012fa5e8
blob - f120798b16e653a7e811f59c25faa77f62273169
blob + 9f05cca64a73b00c1cebb028d16f3bd436fc1b1d
--- gotwebd/config.c
+++ gotwebd/config.c
int
config_init(struct gotwebd *env)
{
+ int i;
+
strlcpy(env->httpd_chroot, D_HTTPD_CHROOT, sizeof(env->httpd_chroot));
env->prefork_gotwebd = GOTWEBD_NUMPROC;
TAILQ_INIT(&env->sockets);
TAILQ_INIT(&env->addresses);
+ for (i = 0; i < PRIV_FDS__MAX; i++)
+ env->priv_fd[i] = -1;
+
+ for (i = 0; i < GOTWEB_PACK_NUM_TEMPFILES; i++)
+ env->pack_fds[i] = -1;
+
return 0;
}
struct socket *sock = NULL;
struct socket_conf sock_conf;
uint8_t *p = imsg->data;
- int i;
if (IMSG_DATA_SIZE(imsg) != sizeof(sock_conf))
fatalx("%s: wrong size", __func__);
TAILQ_INSERT_TAIL(&env->sockets, sock, entry);
- for (i = 0; i < PRIV_FDS__MAX; i++)
- sock->priv_fd[i] = -1;
-
- for (i = 0; i < GOTWEB_PACK_NUM_TEMPFILES; i++)
- sock->pack_fds[i] = -1;
-
/* log new socket info */
log_debug("%s: id=%d af_type=%s socket_path=%s",
__func__, sock->conf.id,
}
int
-config_setfd(struct gotwebd *env, struct socket *sock)
+config_setfd(struct gotwebd *env)
{
int i, j, ret, fd;
if (fd == -1)
fatal("got_opentemp");
if (imsg_compose_event(&env->iev_server[j],
- IMSG_CFG_FD, 0, -1, fd, &sock->conf.id,
- sizeof(sock->conf.id)) == -1)
+ IMSG_CFG_FD, 0, -1, fd, NULL, 0) == -1)
fatal("imsg_compose_event IMSG_CFG_FD");
do {
int
config_getfd(struct gotwebd *env, struct imsg *imsg)
{
- struct socket *sock;
- uint8_t *p = imsg->data;
- int sock_id, match = 0, i, j;
+ int match = 0, i, j;
+ const int nfds = GOTWEB_PACK_NUM_TEMPFILES + PRIV_FDS__MAX;
- if (IMSG_DATA_SIZE(imsg) != sizeof(sock_id))
+ if (imsg_get_len(imsg) != 0)
fatalx("%s: wrong size", __func__);
- memcpy(&sock_id, p, sizeof(sock_id));
+ for (i = 0; i < nfds; i++) {
+ if (i < PRIV_FDS__MAX && env->priv_fd[i] == -1) {
+ env->priv_fd[i] = imsg_get_fd(imsg);
+ log_debug("%s: assigning priv_fd %d",
+ __func__, env->priv_fd[i]);
+ match = 1;
+ break;
+ }
- TAILQ_FOREACH(sock, &env->sockets, entry) {
- const int nfds = (GOTWEB_PACK_NUM_TEMPFILES + PRIV_FDS__MAX);
- for (i = 0; i < nfds; i++) {
- if (i < PRIV_FDS__MAX && sock->priv_fd[i] == -1) {
- sock->priv_fd[i] = imsg_get_fd(imsg);
- log_debug("%s: assigning socket %d priv_fd %d",
- __func__, sock_id, sock->priv_fd[i]);
- match = 1;
- break;
- }
-
- j = i - PRIV_FDS__MAX;
- if (sock->pack_fds[j] == -1) {
- sock->pack_fds[j] = imsg_get_fd(imsg);
- log_debug("%s: assigning socket %d pack_fd %d",
- __func__, sock_id, sock->pack_fds[j]);
- match = 1;
- break;
- }
+ j = i - PRIV_FDS__MAX;
+ if (env->pack_fds[j] == -1) {
+ env->pack_fds[j] = imsg_get_fd(imsg);
+ log_debug("%s: assigning pack_fd %d",
+ __func__, env->pack_fds[j]);
+ match = 1;
+ break;
}
}
blob - 705f38f364465ae903d2748262dbfbe4d65447d5
blob + 576b6064f0ed5912b47df984533e92f6c2e11a3c
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
struct request *c)
{
const struct got_error *error = NULL;
- struct socket *sock = c->sock;
struct server *srv = c->srv;
struct transport *t = c->t;
struct repo_dir *repo_dir;
goto err;
}
- error = got_repo_open(&t->repo, repo_dir->path, NULL, sock->pack_fds);
+ error = got_repo_open(&t->repo, repo_dir->path, NULL,
+ gotwebd_env->pack_fds);
if (error)
goto err;
error = gotweb_get_repo_description(&repo_dir->description, srv,
blob - e6c663ff42ff32e1e3f11d9873f7735b9f1eb98e
blob + 8c143948a32c1b3a74f434684f88151163b53cf9
--- gotwebd/gotwebd.c
+++ gotwebd/gotwebd.c
TAILQ_FOREACH(sock, &env->sockets, entry) {
if (config_setsock(env, sock) == -1)
fatalx("%s: send socket error", __func__);
- if (config_setfd(env, sock) == -1)
- fatalx("%s: send priv_fd error", __func__);
}
+
+ /* send the temp files */
+ if (config_setfd(env) == -1)
+ fatalx("%s: send priv_fd error", __func__);
if (main_compose_sockets(env, IMSG_CFG_DONE, -1, NULL, 0) == -1)
fatal("main_compose_sockets IMSG_CFG_DONE");
blob - 54d00805fd26e7a6b11e21510aad032bf7d9e1bc
blob + 965575a81e6fa9466d7fa736d9d04e7fdd4d95e5
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
struct socket_conf conf;
int fd;
- int pack_fds[GOTWEB_PACK_NUM_TEMPFILES];
- int priv_fd[PRIV_FDS__MAX];
-
struct event evt;
struct event ev;
struct event pause;
struct serverlist servers;
struct socketlist sockets;
struct addresslist addresses;
+
+ int pack_fds[GOTWEB_PACK_NUM_TEMPFILES];
+ int priv_fd[PRIV_FDS__MAX];
char *user;
const char *gotwebd_conffile;
int config_getserver(struct gotwebd *, struct imsg *);
int config_setsock(struct gotwebd *, struct socket *);
int config_getsock(struct gotwebd *, struct imsg *);
-int config_setfd(struct gotwebd *, struct socket *);
+int config_setfd(struct gotwebd *);
int config_getfd(struct gotwebd *, struct imsg *);
int config_getcfg(struct gotwebd *, struct imsg *);
int config_init(struct gotwebd *);
blob - 4be3e313ba6f47241bfb619b9f17e04e0b2bddf8
blob + e4e422a7568c7bafebdb57d3377c40636ff1945b
--- gotwebd/sockets.c
+++ gotwebd/sockets.c
c->fd = s;
c->sock = sock;
- memcpy(c->priv_fd, sock->priv_fd, sizeof(c->priv_fd));
+ memcpy(c->priv_fd, gotwebd_env->priv_fd, sizeof(c->priv_fd));
c->buf_pos = 0;
c->buf_len = 0;
c->request_started = 0;