当前位置: 首页>>代码示例>>C++>>正文


C++ VLOG_FATAL函数代码示例

本文整理汇总了C++中VLOG_FATAL函数的典型用法代码示例。如果您正苦于以下问题:C++ VLOG_FATAL函数的具体用法?C++ VLOG_FATAL怎么用?C++ VLOG_FATAL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VLOG_FATAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_sysconf_buffer_size

/* Return the maximun suggested buffer size for both getpwname_r()
 * and getgrnam_r().
 *
 * This size may still not be big enough. in case getpwname_r()
 * and friends return ERANGE, a larger buffer should be supplied to
 * retry. (The man page did not specify the max size to stop at, we
 * will keep trying with doubling the buffer size for each round until
 * the size wrapps around size_t.  */
static size_t
get_sysconf_buffer_size(void)
{
    size_t bufsize, pwd_bs = 0, grp_bs = 0;
    const size_t default_bufsize = 1024;

    errno = 0;
    if ((pwd_bs = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) {
        if (errno) {
            VLOG_FATAL("%s: Read initial passwordd struct size "
                       "failed (%s), aborting. ", pidfile,
                       ovs_strerror(errno));
        }
    }

    if ((grp_bs = sysconf(_SC_GETGR_R_SIZE_MAX)) == -1) {
        if (errno) {
            VLOG_FATAL("%s: Read initial group struct size "
                       "failed (%s), aborting. ", pidfile,
                       ovs_strerror(errno));
        }
    }

    bufsize = MAX(pwd_bs, grp_bs);
    return bufsize ? bufsize : default_bufsize;
}
开发者ID:numansiddique,项目名称:ovs,代码行数:34,代码来源:daemon-unix.c

示例2: make_pidfile

/* If a pidfile has been configured, creates it and stores the running
 * process's pid in it.  Ensures that the pidfile will be deleted when the
 * process exits. */
static void
make_pidfile(void)
{
    int error;

    error = GetFileAttributes(pidfile);
    if (error != INVALID_FILE_ATTRIBUTES) {
        /* pidfile exists. Try to unlink() it. */
        error = unlink(pidfile);
        if (error) {
            VLOG_FATAL("Failed to delete existing pidfile %s (%s)", pidfile,
                       ovs_strerror(errno));
        }
    }

    filep_pidfile = fopen(pidfile, "w");
    if (filep_pidfile == NULL) {
        VLOG_FATAL("failed to open %s (%s)", pidfile, ovs_strerror(errno));
    }

    fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);

    fprintf(filep_pidfile, "%d\n", _getpid());
    if (fflush(filep_pidfile) == EOF) {
        VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
    }

    /* Don't close the pidfile till the process exits. */
}
开发者ID:AlexanderChou,项目名称:ovs,代码行数:32,代码来源:daemon-windows.c

示例3: daemonize_start

/* If daemonization is configured, then starts daemonization, by forking and
 * returning in the child process.  The parent process hangs around until the
 * child lets it know either that it completed startup successfully (by calling
 * daemon_complete()) or that it failed to start up (by exiting with a nonzero
 * exit code). */
void
daemonize_start(bool access_datapath)
{
    assert_single_threaded();
    daemonize_fd = -1;

    if (switch_user) {
        daemon_become_new_user__(access_datapath);
        switch_user = false;
    }

    if (detach) {
        pid_t pid;

        if (fork_and_wait_for_startup(&daemonize_fd, &pid)) {
            VLOG_FATAL("could not detach from foreground session");
        }
        if (pid > 0) {
            /* Running in parent process. */
            exit(0);
        }

        /* Running in daemon or monitor process. */
        setsid();
    }

    if (monitor) {
        int saved_daemonize_fd = daemonize_fd;
        pid_t daemon_pid;

        if (fork_and_wait_for_startup(&daemonize_fd, &daemon_pid)) {
            VLOG_FATAL("could not initiate process monitoring");
        }
        if (daemon_pid > 0) {
            /* Running in monitor process. */
            fork_notify_startup(saved_daemonize_fd);
            if (detach) {
                close_standard_fds();
            }
            monitor_daemon(daemon_pid);
        }
        /* Running in daemon process. */
    }

    forbid_forking("running in daemon process");

    if (pidfile) {
        make_pidfile();
    }

    /* Make sure that the unixctl commands for vlog get registered in a
     * daemon, even before the first log message. */
    vlog_init();
}
开发者ID:blp,项目名称:ovs-reviews,代码行数:59,代码来源:daemon-unix.c

示例4: check_already_running

/* Checks whether a process with the given 'pidfile' is already running and,
 * if so, aborts.  If 'pidfile' is stale, deletes it. */
static void
check_already_running(void)
{
    long int pid = read_pidfile__(pidfile, true);
    if (pid > 0) {
        VLOG_FATAL("%s: already running as pid %ld, aborting", pidfile, pid);
    } else if (pid < 0) {
        VLOG_FATAL("%s: pidfile check failed (%s), aborting",
                   pidfile, ovs_strerror(-pid));
    }
}
开发者ID:Milstein,项目名称:ovs,代码行数:13,代码来源:daemon.c

示例5: fork_and_wait_for_startup

/* Forks, then:
 *
 *   - In the parent, waits for the child to signal that it has completed its
 *     startup sequence.  Then stores -1 in '*fdp' and returns the child's pid.
 *
 *   - In the child, stores a fd in '*fdp' and returns 0.  The caller should
 *     pass the fd to fork_notify_startup() after it finishes its startup
 *     sequence.
 *
 * If something goes wrong with the fork, logs a critical error and aborts the
 * process. */
static pid_t
fork_and_wait_for_startup(int *fdp)
{
    int fds[2];
    pid_t pid;

    xpipe(fds);

    pid = fork_and_clean_up();
    if (pid > 0) {
        /* Running in parent process. */
        size_t bytes_read;
        char c;

        close(fds[1]);
        if (read_fully(fds[0], &c, 1, &bytes_read) != 0) {
            int retval;
            int status;

            do {
                retval = waitpid(pid, &status, 0);
            } while (retval == -1 && errno == EINTR);

            if (retval == pid) {
                if (WIFEXITED(status) && WEXITSTATUS(status)) {
                    /* Child exited with an error.  Convey the same error
                     * to our parent process as a courtesy. */
                    exit(WEXITSTATUS(status));
                } else {
                    char *status_msg = process_status_msg(status);
                    VLOG_FATAL("fork child died before signaling startup (%s)",
                               status_msg);
                }
            } else if (retval < 0) {
                VLOG_FATAL("waitpid failed (%s)", ovs_strerror(errno));
            } else {
                OVS_NOT_REACHED();
            }
        }
        close(fds[0]);
        *fdp = -1;
    } else if (!pid) {
        /* Running in child process. */
        close(fds[0]);
        *fdp = fds[1];
    }

    return pid;
}
开发者ID:Milstein,项目名称:ovs,代码行数:60,代码来源:daemon.c

示例6: fork_and_wait_for_startup

static pid_t
fork_and_wait_for_startup(int *fdp)
{
    int fds[2];
    pid_t pid;

    xpipe(fds);

    pid = fork();
    if (pid > 0) {
        /* Running in parent process. */
        size_t bytes_read;
        char c;

        close(fds[1]);
        fatal_signal_fork();
        if (read_fully(fds[0], &c, 1, &bytes_read) != 0) {
            int retval;
            int status;

            do {
                retval = waitpid(pid, &status, 0);
            } while (retval == -1 && errno == EINTR);

            if (retval == pid
                && WIFEXITED(status)
                && WEXITSTATUS(status)) {
                /* Child exited with an error.  Convey the same error to
                 * our parent process as a courtesy. */
                exit(WEXITSTATUS(status));
            }

            VLOG_FATAL("fork child failed to signal startup (%s)",
                       strerror(errno));
        }
        close(fds[0]);
        *fdp = -1;
    } else if (!pid) {
        /* Running in child process. */
        close(fds[0]);
        time_postfork();
        lockfile_postfork();
        *fdp = fds[1];
    } else {
        VLOG_FATAL("fork failed (%s)", strerror(errno));
    }

    return pid;
}
开发者ID:Danesca,项目名称:openvswitch,代码行数:49,代码来源:daemon.c

示例7: fatal_signal_init

static void
fatal_signal_init(void)
{
    static bool inited = false;

    if (!inited) {
        size_t i;

        inited = true;

        xpipe(signal_fds);
        set_nonblocking(signal_fds[0]);
        set_nonblocking(signal_fds[1]);

        sigemptyset(&fatal_signal_set);
        for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
            int sig_nr = fatal_signals[i];
            struct sigaction old_sa;

            sigaddset(&fatal_signal_set, sig_nr);
            xsigaction(sig_nr, NULL, &old_sa);
            if (old_sa.sa_handler == SIG_DFL
                && signal(sig_nr, fatal_signal_handler) == SIG_ERR) {
                VLOG_FATAL("signal failed (%s)", strerror(errno));
            }
        }
        atexit(atexit_handler);
    }
}
开发者ID:Danesca,项目名称:openvswitch,代码行数:29,代码来源:fatal-signal.c

示例8: set_config_failure_actions

/* In case of an unexpected termination, configure the action to be
 * taken. */
static void
set_config_failure_actions()
{
    /* In case of a failure, restart the process the first two times
     * After 'dwResetPeriod', the failure count is reset. */
    SC_ACTION fail_action[3] = {
        {SC_ACTION_RESTART, 0},
        {SC_ACTION_RESTART, 0},
        {SC_ACTION_NONE, 0}
    };
    SERVICE_FAILURE_ACTIONS service_fail_action;

    /* Reset failure count after (in seconds). */
    service_fail_action.dwResetPeriod = 10;

    /* Reboot message. */
    service_fail_action.lpRebootMsg = NULL;

    /* The command line of the process. */
    service_fail_action.lpCommand = NULL;

    /* Number of elements in 'fail_actions'. */
    service_fail_action.cActions = sizeof(fail_action)/sizeof(fail_action[0]);

    /* A pointer to an array of SC_ACTION structures. */
    service_fail_action.lpsaActions = fail_action;

    if (!ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS,
                              &service_fail_action)) {
        char *msg_buf = ovs_lasterror_to_string();
        VLOG_FATAL("Failed to configure service fail actions (%s).", msg_buf);
    }
}
开发者ID:Samuel-Ghinet,项目名称:openvswitch-hyperv,代码行数:35,代码来源:daemon-windows.c

示例9: fatal_signal_init

/* Initializes the fatal signal handling module.  Calling this function is
 * optional, because calling any other function in the module will also
 * initialize it.  However, in a multithreaded program, the module must be
 * initialized while the process is still single-threaded. */
void
fatal_signal_init(void)
{
    static bool inited = false;

    if (!inited) {
        size_t i;

        assert_single_threaded();
        inited = true;

        ovs_mutex_init_recursive(&mutex);
        xpipe_nonblocking(signal_fds);

        for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
            int sig_nr = fatal_signals[i];
            struct sigaction old_sa;

            xsigaction(sig_nr, NULL, &old_sa);
            if (old_sa.sa_handler == SIG_DFL
                && signal(sig_nr, fatal_signal_handler) == SIG_ERR) {
                VLOG_FATAL("signal failed (%s)", ovs_strerror(errno));
            }
        }
        atexit(atexit_handler);
    }
}
开发者ID:MohanaPriya26,项目名称:ovs-reviews,代码行数:31,代码来源:fatal-signal.c

示例10: ofputil_versions_from_string

uint32_t
ofputil_versions_from_string(const char *s)
{
    size_t i = 0;
    uint32_t bitmap = 0;

    while (s[i]) {
        size_t j;
        int version;
        char *key;

        if (is_delimiter(s[i])) {
            i++;
            continue;
        }
        j = 0;
        while (s[i + j] && !is_delimiter(s[i + j])) {
            j++;
        }
        key = xmemdup0(s + i, j);
        version = ofputil_version_from_string(key);
        if (!version) {
            VLOG_FATAL("Unknown OpenFlow version: \"%s\"", key);
        }
        free(key);
        bitmap |= 1u << version;
        i += j;
    }

    return bitmap;
}
开发者ID:JScheurich,项目名称:ovs,代码行数:31,代码来源:ofp-protocol.c

示例11: xgettimeofday

void
xgettimeofday(struct timeval *tv)
{
    if (gettimeofday(tv, NULL) == -1) {
        VLOG_FATAL("gettimeofday failed (%s)", ovs_strerror(errno));
    }
}
开发者ID:PatrickGuo,项目名称:ovs-2.1.3,代码行数:7,代码来源:timeval.c

示例12: check_service

/* Check whether 'program_name' has been created as a service. */
static void
check_service()
{
    /* Establish a connection to the local service control manager. */
    manager = OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
    if (!manager) {
        char *msg_buf = ovs_lasterror_to_string();
        VLOG_FATAL("Failed to open the service control manager (%s).",
                   msg_buf);
    }

    service = OpenService(manager, program_name, SERVICE_ALL_ACCESS);
    if (!service) {
        char *msg_buf = ovs_lasterror_to_string();
        VLOG_FATAL("Failed to open service (%s).", msg_buf);
    }
}
开发者ID:Samuel-Ghinet,项目名称:openvswitch-hyperv,代码行数:18,代码来源:daemon-windows.c

示例13: daemon_switch_user

static void
daemon_switch_user(const uid_t uid, const char *user)
{
    if ((setuid(uid) == -1) || !uid_verify(uid)) {
        VLOG_FATAL("%s: fail to switch user to %s, aborting",
                   pidfile, user);
    }
}
开发者ID:dventurino,项目名称:ovs,代码行数:8,代码来源:daemon-unix.c

示例14: daemon_switch_group

static void
daemon_switch_group(gid_t gid)
{
    if ((setgid(gid) == -1) || !gid_verify(gid)) {
        VLOG_FATAL("%s: fail to switch group to gid as %d, aborting",
                   pidfile, gid);
    }
}
开发者ID:dventurino,项目名称:ovs,代码行数:8,代码来源:daemon-unix.c

示例15: get_entropy_or_die

/* Initializes 'buffer' with 'n' bytes of high-quality random numbers.  Exits
 * if an error occurs. */
void
get_entropy_or_die(void *buffer, size_t n)
{
    int error = get_entropy(buffer, n);
    if (error) {
        VLOG_FATAL("%s: read error (%s)",
                   urandom, ovs_retval_to_string(error));
    }
}
开发者ID:David-B55,项目名称:ovs,代码行数:11,代码来源:entropy.c


注:本文中的VLOG_FATAL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。