On Fri, Jul 11, 2014 at 11:22:31AM -0400, Jan Harkes wrote:
> I'll probably end up changing your patch to just remove all of the code
> that tries to open the file instead of leaving the broken code hanging
> around in an #if 0.

FWIIW attaching the actual patch that we apply.

Regards,
Rune
>From c046ee16bf13f4d3260c8bbede1350d06ed88508 Mon Sep 17 00:00:00 2001
From: rl <[email protected]>
Date: Thu, 10 Jul 2014 15:04:07 +0200
Subject: [PATCH] Fix file descriptor leak in updateclnt

---
 coda-src/update/updateclnt.cc |   36 ++++++++++++++----------------------
 1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/coda-src/update/updateclnt.cc b/coda-src/update/updateclnt.cc
index 7d96734..ee11f69 100644
--- a/coda-src/update/updateclnt.cc
+++ b/coda-src/update/updateclnt.cc
@@ -242,34 +242,26 @@ int main(int argc, char **argv)
        if (CheckDir("db", 0644)) {
            operatorSecs = 0;  /* if something changed time has elapsed */
            for (int i=0; i<nservers; i++) {
+               RPC2_Handle rpcid;
                if (nservers != 1)
                    vice_dir_init (vicedir, i+1);
                /* signal file server to check data bases */
-               file = fopen(vice_file("srv/pid"), "r");
-               if (file == NULL) {
-                   LogMsg(0, SrvDebugLevel, stdout,
-                          "Fopen failed for file %s with %s\n",
-                          vice_file("srv/pid"),
-                          ViceErrorMsg(errno));
-               } else {
-                   RPC2_Handle rpcid;
-                   if (U_BindToServer(hostlist[i], &rpcid) == RPC2_SUCCESS) {
-                       if (VolUpdateDB(rpcid) == RPC2_SUCCESS) {
-                           LogMsg(0, SrvDebugLevel, stdout,
-                                  "Notifying server %s of database updates\n",
-                                  hostlist[i]);
-                       } else {
-                           LogMsg(0, SrvDebugLevel, stdout,
-                                  "VolUpdateDB failed for host %s\n",
-                                  hostlist[i]);
-                       }
+               if (U_BindToServer(hostlist[i], &rpcid) == RPC2_SUCCESS) {
+                   if (VolUpdateDB(rpcid) == RPC2_SUCCESS) {
+                       LogMsg(0, SrvDebugLevel, stdout,
+                           "Notifying server %s of database updates\n",
+                           hostlist[i]);
                    } else {
                        LogMsg(0, SrvDebugLevel, stdout,
-                            "Bind to server %s for database update failed\n",
-                            hostlist[i]);
-                   }
-                   RPC2_Unbind(rpcid);
+                           "VolUpdateDB failed for host %s\n",
+                           hostlist[i]);
+                  }
+               } else {
+                   LogMsg(0, SrvDebugLevel, stdout,
+                        "Bind to server %s for database update failed\n",
+                        hostlist[i]);
                }
+               RPC2_Unbind(rpcid);
            }
        }
        if (operatorSecs > 0) {
-- 
1.5.4

Reply via email to