Ticket #1523: cgroupfix.diff

File cgroupfix.diff, 2.0 KB (added by wish, 5 years ago)

Patch to fix bugs #1523 and #1524

  • source/libs/uti2/sge_cgroup.c

    diff -ur sge-8.1.8.orig/source/libs/uti2/sge_cgroup.c sge-8.1.8.patched/source/libs/uti2/sge_cgroup.c
    old new  
    119119         snprintf((buffer), sizeof(buffer), "%s/%s", (dir), (tail));    \
    120120   } while(0)
    121121
     122static bool half_initialized= false;
    122123static bool initialized = false;
    123124/* do we have "cpus" or "cpuset.cpus"? */
    124125static bool cpuset_prefix = false;
     
    147148         if (cg_cpuset == group) {
    148149            char path[SGE_PATH_MAX], shortbuf[10];
    149150            size_t l = sizeof shortbuf;
    150 
     151            half_initialized=true;
    151152            build_path(path, group_dir[group], "cpuset.mems");
    152153            cpuset_prefix = file_exists(path);
    153154            if (!cpuset_prefix)
     
    167168            if (l <= 1) {
    168169               WARNING((SGE_EVENT, "Populating "SFN" in " SFN
    169170                        " so cpusets will work",
    170                         cpuset_prefix ? "cpuset.mems" : "mems",
     171                        cpuset_prefix ? "cpuset.cpus" : "cpus",
    171172                        group_dir[group]));
    172173               copy_from_parent (group_dir[group], "cpus");
    173174            }
     
    180181char *
    181182cgroup_dir(cgroup_t group)
    182183{
    183    if (!initialized) abort();
     184   /*We need to retrieve the cpuset directory part way through the initializtion procedure others can wait*/
     185   if (group==cg_cpuset?!half_initialized:!initialized) abort();
    184186   return group_dir[group];
    185187}
    186188
     
    350352   /* For some reason we're not getting the glibc version of dirname
    351353      that doesn't alter its arg.  */
    352354   sge_strlcpy(dirx, dir, sizeof dirx);
    353    if (strncmp(dir, cgroup_dir(cg_cpuset), strlen(cgroup_dir(cg_cpuset)))
     355   if (!strncmp(dir, cgroup_dir(cg_cpuset), strlen(cgroup_dir(cg_cpuset)))
    354356       && cpuset_prefix
    355357       && strncmp("cpuset.", cfile, 7) != 0)
    356358      prefix = "cpuset.";