diff options
author | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2011-11-13 06:45:39 +0100 |
---|---|---|
committer | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2011-11-13 06:45:39 +0100 |
commit | e78481d2e5a4a3ea133980403041579b048ede74 (patch) | |
tree | 4b4daf1920260f40a2d05f8db550dbbce06f9912 | |
parent | 62fbf67c2a27b10e6ff534c7795a96e38d259e55 (diff) | |
download | MAC-Telnet-e78481d2e5a4a3ea133980403041579b048ede74.tar.gz MAC-Telnet-e78481d2e5a4a3ea133980403041579b048ede74.zip |
Code "speedup".
-rw-r--r-- | mactelnetd.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/mactelnetd.c b/mactelnetd.c index 3690d38..99829d3 100644 --- a/mactelnetd.c +++ b/mactelnetd.c @@ -195,6 +195,10 @@ static int find_socket(unsigned char *mac) { if (interfaces[i].in_use && memcmp(mac, interfaces[i].mac_addr, ETH_ALEN) == 0) { return i; } + + if (!interfaces[i].in_use) { + break; + } } return -1; } @@ -455,8 +459,13 @@ static void user_login(struct mt_connection *curconn, struct mt_mactelnet_hdr *p close(sockfd); close(insockfd); for (i = 0; i < MAX_INTERFACES; ++i) { - if (interfaces[i].in_use && interfaces[i].socketfd > 0) + if (interfaces[i].in_use && interfaces[i].socketfd > 0) { close(interfaces[i].socketfd); + } + if (!interfaces[i].in_use) { + break; + } + } setsid(); @@ -770,9 +779,12 @@ void mndp_broadcast() { struct net_interface *interface = &interfaces[i]; struct mt_mndp_hdr *header = (struct mt_mndp_hdr *)&(pdata.data); - if (interfaces[i].in_use == 0 || interfaces[i].has_mac == 0) { + if (interfaces[i].has_mac == 0) { continue; } + if (interfaces[i].in_use == 0) { + break; + } mndp_init_packet(&pdata, 0, 1); mndp_add_attribute(&pdata, MT_MNDPTYPE_ADDRESS, interface->mac_addr, ETH_ALEN); |