Switch to unified view

a/src/main.cxx b/src/main.cxx
...
...
411
411
412
        g_config->get("scsenderpath", senderpath);
412
        g_config->get("scsenderpath", senderpath);
413
        if (g_config->get("scsendermpdport", value))
413
        if (g_config->get("scsendermpdport", value))
414
            sendermpdport = atoi(value.c_str());
414
            sendermpdport = atoi(value.c_str());
415
415
416
        // If a streaming service is enabled, we need a Media
417
        // Server. We let a static ContentDirectory method decide this
418
        // for us. The way we then implement it depends on the command
419
        // line option (see the enum comments near the top of the file):
420
        enableMediaServer = ContentDirectory::mediaServerNeeded();
421
        switch (arg_msmode) {
422
        case MSOnly:
423
            inprocessms = true;
424
            msonly = true;
425
            break;
426
        case Combined:
427
            inprocessms = true;
428
            msonly = false;
429
            break;
430
        case RdrOnly:
431
        case Forked:
432
        default:
433
            inprocessms = false;
434
            msonly = false;
435
            break;
436
        }
437
    } else {
416
    } else {
438
        // g_configfilename is empty. Create an empty config anyway
417
        // g_configfilename is empty. Create an empty config anyway
439
        g_config = new ConfSimple(string(), 1, true);
418
        g_config = new ConfSimple(string(), 1, true);
440
        if (!g_config || !g_config->ok()) {
419
        if (!g_config || !g_config->ok()) {
441
            cerr << "Could not create empty config\n";
420
            cerr << "Could not create empty config\n";
442
            return 1;
421
            return 1;
443
        }
422
        }
444
    }
423
    }
445
424
425
    if (Logger::getTheLog(logfilename) == 0) {
426
        cerr << "Can't initialize log" << endl;
427
        return 1;
428
    }
429
    Logger::getTheLog("")->reopen(logfilename);
430
    Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
431
432
    // If a streaming service is enabled, we need a Media
433
    // Server. We let a static ContentDirectory method decide this
434
    // for us. The way we then implement it depends on the command
435
    // line option (see the enum comments near the top of the file):
436
    enableMediaServer = ContentDirectory::mediaServerNeeded();
437
    switch (arg_msmode) {
438
    case MSOnly:
439
        inprocessms = true;
440
        msonly = true;
441
        break;
442
    case Combined:
443
        inprocessms = true;
444
        msonly = false;
445
        break;
446
    case RdrOnly:
447
    case Forked:
448
    default:
449
        inprocessms = false;
450
        msonly = false;
451
        break;
452
    }
453
446
    // If neither OH nor AV are enable, run as pure media server. This
454
    // If neither OH nor AV are enable, run as pure media server. This
447
    // is another way to do it besides the -m option
455
    // is another way to do it besides the -m option
448
    if (!enableOH && !enableAV) {
456
    if (!enableOH && !enableAV) {
449
        msonly = true;
457
        msonly = true;
450
        // Set inprocessms in this case ! No need to fork
458
        // Set inprocessms in this case ! No need to fork
...
...
454
    if (msonly && !enableMediaServer) {
462
    if (msonly && !enableMediaServer) {
455
        // We used to forbid this, but it's actually ok if we're just using
463
        // We used to forbid this, but it's actually ok if we're just using
456
        // the "mediaserver" to redirect URLs for ohcredentials/Kazoo
464
        // the "mediaserver" to redirect URLs for ohcredentials/Kazoo
457
        ;
465
        ;
458
    }
466
    }
459
460
    if (Logger::getTheLog(logfilename) == 0) {
461
        cerr << "Can't initialize log" << endl;
462
        return 1;
463
    }
464
    Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
465
467
466
    Pidfile pidfile(pidfilename);
468
    Pidfile pidfile(pidfilename);
467
469
468
    // If started by root, we use the pidfile and we will change the
470
    // If started by root, we use the pidfile and we will change the
469
    // uid (later). First part follows
471
    // uid (later). First part follows
...
...
532
534
533
    if (geteuid() == 0) {
535
    if (geteuid() == 0) {
534
        // Need to rewrite pid, it may have changed with the daemon call
536
        // Need to rewrite pid, it may have changed with the daemon call
535
        pidfile.write_pid();
537
        pidfile.write_pid();
536
        if (!logfilename.empty() && logfilename.compare("stderr")) {
538
        if (!logfilename.empty() && logfilename.compare("stderr")) {
537
            if (chown(logfilename.c_str(), runas, -1) < 0) {
539
            if (chown(logfilename.c_str(), runas, -1) < 0 && errno != ENOENT) {
538
                LOGERR("chown("<<logfilename<<") : errno : " << errno << endl);
540
                LOGERR("chown("<<logfilename<<") : errno : " << errno << endl);
539
            }
541
            }
540
        }
542
        }
541
        if (!g_configfilename.empty()) {
543
        if (!g_configfilename.empty()) {
542
            ensureconfreadable(g_configfilename.c_str(), upmpdcliuser.c_str(),
544
            ensureconfreadable(g_configfilename.c_str(), upmpdcliuser.c_str(),