dingstudio / rpms / konsole

Forked from rpms/konsole a year ago
Clone

Blame SOURCES/konsole-avoid-repeated-calls-to-redusername-method.patch

5f3c2e
From 67aa1f8fb71df941bd62ebc046a182d2cba1f9d7 Mon Sep 17 00:00:00 2001
5f3c2e
From: Siteshwar Vashisht <svashisht@redhat.com>
5f3c2e
Date: Fri, 18 Dec 2015 20:42:12 +0530
5f3c2e
Subject: [PATCH] Avoid repeated calls to readUserName() method
5f3c2e
5f3c2e
readUserName() method calls getpwuid_r() function. If user information
5f3c2e
is retrieved from remote server, it would flood the remote server
5f3c2e
with repeated requests. Username should be retrieved only once for a
5f3c2e
ProcessInfo instance.
5f3c2e
---
5f3c2e
 src/ProcessInfo.cpp | 4 +++-
5f3c2e
 1 file changed, 3 insertions(+), 1 deletion(-)
5f3c2e
5f3c2e
diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp
5f3c2e
index aba138e..78e9f67 100644
5f3c2e
--- a/src/ProcessInfo.cpp
5f3c2e
+++ b/src/ProcessInfo.cpp
5f3c2e
@@ -464,7 +464,9 @@ private:
5f3c2e
             const int uid = uidString.toInt(&ok;;
5f3c2e
             if (ok)
5f3c2e
                 setUserId(uid);
5f3c2e
-            readUserName();
5f3c2e
+
5f3c2e
+            if (userName().isEmpty())
5f3c2e
+                readUserName();
5f3c2e
         } else {
5f3c2e
             setFileError(statusInfo.error());
5f3c2e
             return false;
5f3c2e
-- 
5f3c2e
2.1.0