Browse Source

use same_sockaddr()

master
Olaf Rempel 12 years ago
parent
commit
0b68a8b0f9
3 changed files with 10 additions and 4 deletions
  1. +1
    -4
      connection.c
  2. +7
    -0
      sockaddr.c
  3. +2
    -0
      sockaddr.h

+ 1
- 4
connection.c View File

@@ -269,10 +269,7 @@ int ctcs_httpd_quit(struct httpd_con *con, void *privdata)
list_for_each_entry(torrent, &torrent_list, list) {
struct client_con *search;
list_for_each_entry(search, &torrent->client_list, list) {
if (search->addr.sin_addr.s_addr != addr.sin_addr.s_addr)
continue;

if (search->addr.sin_port != addr.sin_port)
if (!same_sockaddr(&search->addr, &addr))
continue;

write(event_get_fd(search->event), "CTQUIT\n", 7);


+ 7
- 0
sockaddr.c View File

@@ -90,3 +90,10 @@ char * get_sockaddr_buf(struct sockaddr_in *addr)
get_sockaddr(ret, sizeof(ret), addr);
return ret;
}

int same_sockaddr(struct sockaddr_in *a, struct sockaddr_in *b)
{
return !((a->sin_family ^ b->sin_family) |
(a->sin_addr.s_addr ^ b->sin_addr.s_addr) |
(a->sin_port ^ b->sin_port));
}

+ 2
- 0
sockaddr.h View File

@@ -9,4 +9,6 @@ int parse_subnet(const char *addr, struct in_addr *net, struct in_addr *mask);
int get_sockaddr(char *buf, int size, struct sockaddr_in *addr);
char * get_sockaddr_buf(struct sockaddr_in *addr);

int same_sockaddr(struct sockaddr_in *a, struct sockaddr_in *b);

#endif /* _SOCKADDR_H_ */

Loading…
Cancel
Save