VirtualBox

Ignore:
Timestamp:
May 1, 2015 10:19:37 AM (10 years ago)
Author:
vboxsync
Message:

VBoxServiceControlSessionForkInit: Some minor cleanup and a couple of code review comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r55579 r55580  
    22672267
    22682268/**
    2269  * Close all formerly opened guest session threads.
    2270  * Note: Caller is responsible for locking!
     2269 * Close all open guest session threads.
     2270 *
     2271 * @note    Caller is responsible for locking!
    22712272 *
    22722273 * @return  IPRT status code.
     
    22842285            VBoxServiceError("Cancelling pending waits failed; rc=%Rrc\n", rc);*/
    22852286
    2286     PVBOXSERVICECTRLSESSIONTHREAD pSessionThread
    2287         = RTListGetFirst(pList, VBOXSERVICECTRLSESSIONTHREAD, Node);
     2287/** @todo r=bird: Why don't you use RTListForEachSafe here?? */
     2288    PVBOXSERVICECTRLSESSIONTHREAD pSessionThread = RTListGetFirst(pList, VBOXSERVICECTRLSESSIONTHREAD, Node);
    22882289    while (pSessionThread)
    22892290    {
    22902291        PVBOXSERVICECTRLSESSIONTHREAD pSessionThreadNext =
    22912292            RTListGetNext(pList, pSessionThread, VBOXSERVICECTRLSESSIONTHREAD, Node);
    2292         bool fLast = RTListNodeIsLast(pList, &pSessionThread->Node);
     2293        bool fLast = RTListNodeIsLast(pList, &pSessionThread->Node); /** @todo r=bird: This isn't necessary, pSessionThreadNext will be NULL! */
    22932294
    22942295        int rc2 = GstCntlSessionThreadDestroy(pSessionThread, uFlags);
     
    23102311}
    23112312
     2313/** @todo r=bird: This isn't a fork in the tranditional unix sense, so please
     2314 * don't confuse any unix guys by using the term.
     2315 * GstCntlSessionChildMain would be a good name.  */
    23122316RTEXITCODE VBoxServiceControlSessionForkInit(int argc, char **argv)
    23132317{
     
    23412345    g_Session.StartupInfo.uSessionID = UINT32_MAX;
    23422346
    2343     int rc = VINF_SUCCESS;
    2344 
    2345     while (   (ch = RTGetOpt(&GetState, &ValueUnion))
    2346            && RT_SUCCESS(rc))
     2347    while ((ch = RTGetOpt(&GetState, &ValueUnion)) != 0)
    23472348    {
    23482349        /* For options that require an argument, ValueUnion has received the value. */
     
    23502351        {
    23512352            case VBOXSERVICESESSIONOPT_LOG_FILE:
    2352                 rc = RTStrCopy(g_szLogFile, sizeof(g_szLogFile), ValueUnion.psz);
     2353            {
     2354                int rc = RTStrCopy(g_szLogFile, sizeof(g_szLogFile), ValueUnion.psz);
    23532355                if (RT_FAILURE(rc))
    23542356                    return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error copying log file name: %Rrc", rc);
    23552357                break;
     2358            }
    23562359#ifdef DEBUG
    23572360            case VBOXSERVICESESSIONOPT_DUMP_STDOUT:
     
    23642367#endif
    23652368            case VBOXSERVICESESSIONOPT_USERNAME:
    2366                 /** @todo Information not needed right now, skip. */
     2369                /* Information not needed right now, skip. */
    23672370                break;
    23682371
     
    23772380#ifdef DEBUG
    23782381            case VBOXSERVICESESSIONOPT_THREAD_ID:
    2379                 /* Not handled. */
     2382                /* Not handled. Mainly for processs listing. */
    23802383                break;
    23812384#endif
     
    23882391            case VINF_GETOPT_NOT_OPTION:
    23892392                /* Ignore; might be "guestsession" main command. */
     2393                /** @todo r=bird: We DO NOT ignore stuff on the command line! */
    23902394                break;
    23912395
    23922396            default:
    23932397                return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown command '%s'", ValueUnion.psz);
    2394                 break; /* Never reached. */
    2395         }
    2396     }
    2397 
    2398     if (RT_FAILURE(rc))
    2399         return RTMsgErrorExit(RTEXITCODE_FAILURE, "Initialization failed with rc=%Rrc", rc);
    2400 
     2398        }
     2399    }
     2400
     2401    /* Check that we've got all the required options. */
    24012402    if (g_Session.StartupInfo.uProtocol == UINT32_MAX)
    24022403        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No protocol version specified");
     
    24062407
    24072408    /* Init the session object. */
    2408     rc = GstCntlSessionInit(&g_Session, uSessionFlags);
     2409    int rc = GstCntlSessionInit(&g_Session, uSessionFlags);
    24092410    if (RT_FAILURE(rc))
    24102411        return RTMsgErrorExit(RTEXITCODE_INIT, "Failed to initialize session object, rc=%Rrc\n", rc);
    24112412
    2412     rc = VBoxServiceLogCreate(strlen(g_szLogFile) ? g_szLogFile : NULL);
     2413    rc = VBoxServiceLogCreate(g_szLogFile[0] ? g_szLogFile : NULL);
    24132414    if (RT_FAILURE(rc))
    24142415        return RTMsgErrorExit(RTEXITCODE_INIT, "Failed to create log file \"%s\", rc=%Rrc\n",
    2415                               strlen(g_szLogFile) ? g_szLogFile : "<None>", rc);
     2416                              g_szLogFile[0] ? g_szLogFile : "<None>", rc);
    24162417
    24172418    RTEXITCODE rcExit = gstcntlSessionForkWorker(&g_Session);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette