[Iftop-users] [PATCH] sethostent() and setprotoent() are not thread safe

Bill Nickless bill at nonick.org
Mon Feb 8 03:15:49 GMT 2021


Remove calls to sethostent() and setprotoent() because they are only
optimizations and are not thread safe.

Signed-off-by: Bill Nickless <bill at nonick.org>
---
 resolver.c  | 1 -
 serv_hash.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/resolver.c b/resolver.c
index 8557125..6c4c21d 100644
--- a/resolver.c
+++ b/resolver.c
@@ -407,7 +407,6 @@ char *do_resolve(struct addr_storage *addr) {

 void resolver_worker(void* ignored) {
     pthread_mutex_lock(&resolver_queue_mutex);
-    sethostent(1);
     while(1) {
         /* Wait until we are told that an address has been added to the
          * queue. */
diff --git a/serv_hash.c b/serv_hash.c
index 279032e..10af520 100644
--- a/serv_hash.c
+++ b/serv_hash.c
@@ -52,7 +52,6 @@ void serv_hash_initialise(hash_type* sh) {
   struct servent* ent;
   struct protoent* pent;
   ip_service* service;
-  setprotoent(1);
   while((ent = getservent()) != NULL) {
     pent = getprotobyname(ent->s_proto);
     if(pent != NULL) {
--
2.25.1



More information about the iftop-users mailing list