aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-28 21:36:42 +0100
committerOmar Polo <op@omarpolo.com>2021-01-28 21:36:42 +0100
commite52e58fae447d8417d95fd677c2c6a523302cedd (patch)
tree3b7680d03f1399f9cfee0d9ebe6362f0a4dcd1f3
parent32693ee6db7adee378cb369874fd0be2bea447cc (diff)
downloadgmid-e52e58fae447d8417d95fd677c2c6a523302cedd.tar.gz
gmid-e52e58fae447d8417d95fd677c2c6a523302cedd.tar.bz2
disable sandbox and let loop exit so we can use gprofgprof
-rw-r--r--Makefile5
-rw-r--r--gmid.c5
-rw-r--r--server.c6
3 files changed, 12 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 3ede9dd..5a5bc09 100644
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,11 @@ y.tab.c: parse.y
SRCS = gmid.c iri.c utf8.c ex.c server.c sandbox.c mime.c puny.c utils.c
OBJS = ${SRCS:.c=.o} lex.yy.o y.tab.o ${COMPAT}
+.c.o:
+ ${CC} -pg -static ${CFLAGS} -c $< -o $@
+
gmid: ${OBJS}
- ${CC} ${OBJS} -o gmid ${LDFLAGS}
+ ${CC} -pg -static ${OBJS} -o gmid ${LDFLAGS}
gg: gg.o iri.o utf8.o ${COMPAT}
${CC} gg.o iri.o utf8.o ${COMPAT} -o $@ ${LDFLAGS}
diff --git a/gmid.c b/gmid.c
index 9ba28e7..0685f24 100644
--- a/gmid.c
+++ b/gmid.c
@@ -394,7 +394,7 @@ listener_main(void)
load_vhosts();
- sandbox();
+ /* sandbox(); */
loop(ctx, sock4, sock6);
return 0;
@@ -597,6 +597,7 @@ main(int argc, char **argv)
default: /* parent */
close(p[1]);
- return executor_main(p[0]);
+ executor_main(p[0]);
+ _exit(0);
}
}
diff --git a/server.c b/server.c
index f19116f..8c2110e 100644
--- a/server.c
+++ b/server.c
@@ -876,7 +876,8 @@ loop(struct tls *ctx, int sock4, int sock6)
fds[1].fd = sock6;
for (;;) {
- if (poll(fds, MAX_USERS, INFTIM) == -1) {
+ int p;
+ if ((p = poll(fds, MAX_USERS, 5 * 1000)) == -1) {
if (errno == EINTR) {
fprintf(stderr, "connected clients: %d\n",
connected_clients);
@@ -884,6 +885,9 @@ loop(struct tls *ctx, int sock4, int sock6)
}
fatal("poll: %s", strerror(errno));
}
+
+ if (p == 0)
+ exit(0);
for (i = 0; i < MAX_USERS; i++) {
if (fds[i].revents == 0)