dingstudio / rpms / konsole

Forked from rpms/konsole a year ago
Clone

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

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