void
classifierd_run(void)
{
    struct ovsdb_idl_txn *txn;

    /* Process a batch of messages from OVSDB. */
    ovsdb_idl_run(idl);

    if (ovsdb_idl_is_lock_contended(idl)) {
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);

        VLOG_ERR_RL(&rl, "Another classifierd process is running, "
                    "disabling this process until it goes away");
        return;
    } else if (!ovsdb_idl_has_lock(idl)) {
        return;
    }

    /* Nothing to do until system has been configured, i.e. cur_cfg > 0. */
    if (!classifierd_system_is_configured()) {
        return;
    }

    /* Update the local configuration and push any changes to the dB. */
    txn = ovsdb_idl_txn_create(idl);
    if (classifierd_reconfigure()) {
        VLOG_DBG("%s: Committing changes\n",__FUNCTION__);
        /* Some OVSDB write needs to happen. */
        ovsdb_idl_txn_commit_block(txn);
    }
    ovsdb_idl_txn_destroy(txn);

    return;
} /* classifierd_run */
示例#2
0
/* Perform all of the per-loop processing. */
static void
daemon_run(void)
{
    unsigned int new_idl_seqno = ovsdb_idl_get_seqno(idl);

    ovsdb_idl_run(idl);

    if (ovsdb_idl_is_lock_contended(idl)) {
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
        VLOG_ERR_RL(&rl, "another ops-usermgmt process is running, "
                    "disabling this process until it goes away");
        return;
    } else if (!ovsdb_idl_has_lock(idl)) {
        return;
    }

    /* Acquired lock, we're officially ops-usermgmt now. */

    if (!populated) {
        /* First time we got this far, populate database from passwd. */
        if (sync_to_db())
            populated = true;
        daemonize_complete();
        vlog_enable_async();
        VLOG_INFO_ONCE("%s (OpenSwitch usermgmt)", program_name);
    }

    if (new_idl_seqno == idl_seqno)
        return;

    /* Change in OVSDB detected. */
    idl_seqno =  new_idl_seqno;

    sync_from_db();
}