[hackers] [quark] another version, behaves better under stress || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Sat, 15 Aug 2009 21:25:32 +0000 (UTC)

changeset: 4:1f90420c4044
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Sat Aug 15 22:25:22 2009 +0100
files: quark.c
description:
another version, behaves better under stress

diff -r f34cc4c3d37e -r 1f90420c4044 quark.c
--- a/quark.c Sat Aug 15 22:11:26 2009 +0100
+++ b/quark.c Sat Aug 15 22:25:22 2009 +0100
@@ -300,7 +300,6 @@
 void
 serve(int fd) {
         int result;
- unsigned int timeout = 1;
         socklen_t salen;
         struct sockaddr sa;
 
@@ -308,8 +307,8 @@
         while(running) {
                 if((cfd = accept(fd, &sa, &salen)) == -1) {
                         /* el cheapo socket release */
- fprintf(stderr, "%s: cannot accept(), sleep %u seconds\n", tstamp(), timeout);
- sleep(timeout++);
+ fprintf(stderr, "%s: cannot accept: %s, sleep a second...\n", tstamp(), strerror(errno));
+ sleep(1);
                         continue;
                 }
                 if(fork() == 0) {
@@ -324,7 +323,6 @@
                         close(cfd);
                         exit(EXIT_SUCCESS);
                 }
- timeout = 1;
         }
         fprintf(stdout, "%s: shutting down\n", tstamp());
 }
Received on Sat Aug 15 2009 - 21:25:32 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:19:06 UTC