commit 0e0ffdbe05a892771d4f3a5b57478e195c639bb0
parent 8f1c773b1712ee11903ea276fb8bc1d0a8846e17
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sun, 27 Jan 2019 17:03:52 +0100
Fork clients.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/beans.c b/beans.c
@@ -105,13 +105,17 @@ run(void) {
int csd, len, tmpsd;
char tmpfn[64] = {0}, *buf, *code;
- size = sizeof conn;
while(1) {
+ size = sizeof conn;
csd = accept(sockd, (struct sockaddr *)&conn, &size);
if(csd == -1) {
fprintf(stderr, "accept(): %s", strerror(errno));
continue;
}
+ if(fork()) {
+ close(csd);
+ continue;
+ }
buf = readall(csd, &len);
if(!(buf && len)) {
sout(csd, "Nothing pasted.\n");
@@ -137,6 +141,7 @@ run(void) {
close(csd);
close(tmpsd);
free(buf);
+ break;
}
}