trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zcorrea <...@git.apache.org>
Subject [GitHub] trafodion pull request #1664: [TRAFODION-2884] Multiple fixes with Name Serv...
Date Fri, 27 Jul 2018 23:27:48 GMT
Github user zcorrea commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1664#discussion_r205920958
  
    --- Diff: core/sqf/monitor/linux/process.cxx ---
    @@ -4775,46 +4818,85 @@ void CProcessContainer::Bcast (struct message_def *msg)
     
     char *CProcessContainer::BuildOurName( int nid, int pid, char *name )
     {
    -    int i;
    -    int rem;
    -    int cnt[4];
    -
         const char method_name[] = "CProcessContainer::BuildOurName";
         TRACE_ENTRY;
     
    -    // Convert Pid into base 35 acsii
    -    cnt[0] = pid / 42875;
    -    rem = pid - ( cnt[0] * 42875 );
    -    cnt[1] = rem / 1225;
    -    rem -= ( cnt[1] * 1225 );
    -    cnt[2] = rem / 35;
    -    rem -= ( cnt[2] * 35 );
    -    cnt[3] = rem;
    +    int i;
    +    int rem;
    +    int cnt[6];
    +
    +    if (!processNameFormatLong_)
    +    {
    +        // Convert Pid into base 35 acsii
    +        cnt[0] = pid / 42875;    // (35 * 35 * 35)
    +        rem = pid - ( cnt[0] * 42875 );
    +        cnt[1] = rem / 1225;     // (35 * 35)
    +        rem -= ( cnt[1] * 1225 );
    +        cnt[2] = rem / 35;
    +        rem -= ( cnt[2] * 35 );
    +        cnt[3] = rem;
    +    
    +        // Process name format long: '$Zxxpppp' xx = nid, pppp = pid
     
    -    // Convert Nid into base 16 acsii
    -    sprintf(name,"$Z%2.2X",nid);
    -    for(i=3; i>=0; i--)
    -    {
    -        if( cnt[i] < 10 )
    -        {
    -            name[i+4] = '0'+cnt[i];
    -        }
    -        else
    +        // Convert Nid into base 16 acsii
    +        sprintf(name,"$Z%2.2X",nid);
    +
    +        // Convert Pid into base 36 ascii
    +        for(i=3; i>=0; i--)
             {
    -            cnt[i] -= 10;
    -            // we are skipping cap 'o' because it looks like zero.
    -            if( cnt[i] >= 14 )
    +            if( cnt[i] < 10 )
                 {
    -                name[i+4] = 'P'+(cnt[i]-14);
    +                name[i+4] = '0'+cnt[i];
                 }
                 else
                 {
    -                name[i+4] = 'A'+cnt[i];
    +                cnt[i] -= 10;
    +                // we are skipping cap 'o' because it looks like zero.
    +                if( cnt[i] >= 14 )
    +                {
    +                    name[i+4] = 'P'+(cnt[i]-14);
    +                }
    +                else
    +                {
    +                    name[i+4] = 'A'+cnt[i];
    +                }
                 }
             }
    +        name[8] = '\0';
    +    }
    +    else
    +    {
    +        // We are skipping 'A', 'I', 'O', and 'U' to distinguish between zero
    +        // and one digits, and for political correctness in generated names
    --- End diff --
    
    I could not think of any of the more mundane four-letter words. Can you? This is what
we used in the NonStop OSS file system.


---

Mime
View raw message