diff options
author | Fabien Siron <fabien.siron@epita.fr> | 2016-06-22 13:51:49 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-06-05 11:52:11 +0000 |
commit | 103744d27172a2a723919d2c8f59f4db2714e5a5 (patch) | |
tree | 38343d1ac8a06fc9d984091e000cf8ef005465fb /socketutils.c | |
parent | 0a9d8bfd843008fdfef14945f2ccc0052b6d27ba (diff) | |
download | strace-103744d27172a2a723919d2c8f59f4db2714e5a5.tar.gz |
socketutils.c: introduce cache_inode_details
cache_inode_details gives a way to obtain cache information without
printing it.
* socketutils.c (cache_and_print_inode_details): Rename
to cache_inode_details. Do not print cached information.
(inet_parse_response, unix_parse_response, netlink_parse_response):
Use cache_inode_details instead of cache_and_print_inode_details.
(inet_print, unix_print, netlink_print): Call
print_sockaddr_by_inode_cached.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Diffstat (limited to 'socketutils.c')
-rw-r--r-- | socketutils.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/socketutils.c b/socketutils.c index 38b0b158e..133e21602 100644 --- a/socketutils.c +++ b/socketutils.c @@ -57,14 +57,13 @@ static cache_entry cache[CACHE_SIZE]; #define CACHE_MASK (CACHE_SIZE - 1) static int -cache_and_print_inode_details(const unsigned long inode, char *const details) +cache_inode_details(const unsigned long inode, char *const details) { cache_entry *e = &cache[inode & CACHE_MASK]; free(e->details); e->inode = inode; e->details = details; - tprints(details); return 1; } @@ -185,7 +184,7 @@ inet_parse_response(const char *const proto_name, const void *const data, return false; } - return cache_and_print_inode_details(inode, details); + return cache_inode_details(inode, details); } static bool @@ -245,7 +244,8 @@ inet_print(const int fd, const int family, const int protocol, const unsigned long inode, const char *proto_name) { return inet_send_query(fd, family, protocol) - && receive_responses(fd, inode, proto_name, inet_parse_response); + && receive_responses(fd, inode, proto_name, inet_parse_response) + && print_sockaddr_by_inode_cached(inode); } static bool @@ -344,7 +344,7 @@ unix_parse_response(const char *proto_name, const void *data, peer_str, path_str) < 0) return -1; - return cache_and_print_inode_details(inode, details); + return cache_inode_details(inode, details); } static bool @@ -398,14 +398,15 @@ netlink_parse_response(const char *proto_name, const void *data, return -1; } - return cache_and_print_inode_details(inode, details); + return cache_inode_details(inode, details); } static bool unix_print(const int fd, const unsigned long inode) { return unix_send_query(fd, inode) - && receive_responses(fd, inode, "UNIX", unix_parse_response); + && receive_responses(fd, inode, "UNIX", unix_parse_response) + && print_sockaddr_by_inode_cached(inode); } static bool @@ -437,7 +438,8 @@ netlink_print(const int fd, const unsigned long inode) { return netlink_send_query(fd, inode) && receive_responses(fd, inode, "NETLINK", - netlink_parse_response); + netlink_parse_response) + && print_sockaddr_by_inode_cached(inode); } static const struct { |