[torquedev] [Bug 182] New: serverdb is saved out with missing data

bugzilla-daemon at supercluster.org bugzilla-daemon at supercluster.org
Mon Apr 23 23:40:23 MDT 2012


http://www.clusterresources.com/bugzilla/show_bug.cgi?id=182

           Summary: serverdb is saved out with missing data
           Product: TORQUE
           Version: 3.0.x
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: pbs_server
        AssignedTo: dbeer at adaptivecomputing.com
        ReportedBy: rhys.hill at adelaide.edu.au
                CC: torquedev at supercluster.org
   Estimated Hours: 0.0


The server DB is corrupted on save in 4.0.1 r6023, but the following patch
fixes it. The bug is that attr_to_str calls size_to_dynamic_string assuming it
will append to the string, when it currently replaces it. It looked to me like
it was supposed to append, so the following shortens and corrects
size_to_dynamic_string

I'm not 100% convinced this is doing the right thing, my server DB currently
says that we've got 67645734912kb of memory allocated, with is ~63TB. If that
were bytes, it'd be about right. I wonder if the code also needs a case for
szv.atsv_shift=0 or similar?

Index: src/lib/Libutils/u_dynamic_string.c
===================================================================
--- src/lib/Libutils/u_dynamic_string.c    (revision 6023)
+++ src/lib/Libutils/u_dynamic_string.c    (working copy)
@@ -155,55 +155,36 @@

   {
   char buffer[MAXLINE];
-  int  add_one = FALSE;
-
-  if (ds->used == 0)
-    add_one = TRUE;
-
+  size_t str_size = 0;
+  
+  // We insert any old suffix to start with and fix it below:
   sprintf(buffer, "%lukb", szv.atsv_num);
-  resize_if_needed(ds, buffer);
-
-  sprintf(buffer, "%lu", szv.atsv_num);
-  strcat(ds->str, buffer);
+  str_size = strlen( buffer );

   switch (szv.atsv_shift)
     {
     case 10:
-
-      strcat(ds->str, "kb");
-
+      buffer[str_size - 2] = 'k';
       break;

     case 20:
-
-      strcat(ds->str, "mb");
-
+      buffer[str_size - 2] = 'm';
       break;

     case 30: 
-
-      strcat(ds->str, "gb");
-
+      buffer[str_size - 2] = 'g';
       break;

     case 40:
-
-      strcat(ds->str, "tb");
-
+      buffer[str_size - 2] = 't';
       break;

     case 50:
-
-      strcat(ds->str, "pb");
-
+      buffer[str_size - 2] = 'p';
       break;
     }
-
-  ds->used += strlen(buffer) + 2;
-  if (add_one == TRUE)
-    ds->used += 1;
-
-  return(PBSE_NONE);
+  
+  return append_dynamic_string( ds, buffer );
   } /* END size_to_dynamic_string() */

-- 
Configure bugmail: http://www.clusterresources.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the torquedev mailing list