summaryrefslogtreecommitdiff
path: root/ipsvd/ipsvd_perhost.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-02 12:37:28 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-02 12:37:28 +0000
commit729bd9e0b0d5977e9c2c2a4eff7e2f0ca2ad4b9e (patch)
treed5cb1a1c7c41b2681ca867c57c3b4e473c0a56be /ipsvd/ipsvd_perhost.c
parentb05a939bcc0249fe8bd94b9795db8f8d93c3921e (diff)
downloadbusybox-w32-729bd9e0b0d5977e9c2c2a4eff7e2f0ca2ad4b9e.tar.gz
busybox-w32-729bd9e0b0d5977e9c2c2a4eff7e2f0ca2ad4b9e.tar.bz2
busybox-w32-729bd9e0b0d5977e9c2c2a4eff7e2f0ca2ad4b9e.zip
test: comment out unused code
udpsvd: fake it compile tcpsvd: more optimal memorizing of IP's for -C
Diffstat (limited to 'ipsvd/ipsvd_perhost.c')
-rw-r--r--ipsvd/ipsvd_perhost.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/ipsvd/ipsvd_perhost.c b/ipsvd/ipsvd_perhost.c
index 1c5c12af5..281f708b0 100644
--- a/ipsvd/ipsvd_perhost.c
+++ b/ipsvd/ipsvd_perhost.c
@@ -22,26 +22,26 @@ void ipsvd_perhost_init(unsigned c)
22 cclen = c; 22 cclen = c;
23} 23}
24 24
25unsigned ipsvd_perhost_add(const char *ip, unsigned maxconn, struct hcc **hccpp) 25unsigned ipsvd_perhost_add(char *ip, unsigned maxconn, struct hcc **hccpp)
26{ 26{
27 unsigned i; 27 unsigned i;
28 unsigned conn = 1; 28 unsigned conn = 1;
29 int p = -1; 29 int freepos = -1;
30 30
31 for (i = 0; i < cclen; ++i) { 31 for (i = 0; i < cclen; ++i) {
32 if (cc[i].ip[0] == 0) { 32 if (!cc[i].ip) {
33 if (p == -1) p = i; 33 freepos = i;
34 continue; 34 continue;
35 } 35 }
36 if (strncmp(cc[i].ip, ip, sizeof(cc[i].ip)) == 0) { 36 if (strcmp(cc[i].ip, ip) == 0) {
37 conn++; 37 conn++;
38 continue; 38 continue;
39 } 39 }
40 } 40 }
41 if (p == -1) return 0; 41 if (freepos == -1) return 0;
42 if (conn <= maxconn) { 42 if (conn <= maxconn) {
43 strcpy(cc[p].ip, ip); 43 cc[freepos].ip = ip;
44 *hccpp = &cc[p]; 44 *hccpp = &cc[freepos];
45 } 45 }
46 return conn; 46 return conn;
47} 47}
@@ -51,7 +51,8 @@ void ipsvd_perhost_remove(int pid)
51 unsigned i; 51 unsigned i;
52 for (i = 0; i < cclen; ++i) { 52 for (i = 0; i < cclen; ++i) {
53 if (cc[i].pid == pid) { 53 if (cc[i].pid == pid) {
54 cc[i].ip[0] = 0; 54 free(cc[i].ip);
55 cc[i].ip = NULL;
55 cc[i].pid = 0; 56 cc[i].pid = 0;
56 return; 57 return;
57 } 58 }