예제 #1
0
static void test_set_backend_ids_for_disabled(session &sess)
{
	server_node &node = global_data->nodes.back();

	auto ids = generate_ids(16);

	ELLIPTICS_REQUIRE(async_set_result, sess.set_backend_ids(node.remote(), 4, ids));

	backend_status_result_entry result = async_set_result.get_one();
	BOOST_REQUIRE(result.is_valid());
	BOOST_REQUIRE_EQUAL(result.count(), 1);

	dnet_backend_status *status = result.backend(0);
	BOOST_REQUIRE_EQUAL(status->backend_id, 4);
	BOOST_REQUIRE_EQUAL(status->state, DNET_BACKEND_DISABLED);

	ELLIPTICS_REQUIRE(async_enable_result, sess.enable_backend(node.remote(), 4));

	// Wait 0.1 secs to ensure that route list was changed
	usleep(100 * 1000);

	auto route_ids = backend_ids(sess, node.remote(), 4);
	BOOST_REQUIRE_EQUAL(ids.size(), route_ids.size());
	BOOST_REQUIRE(compare_ids(ids, route_ids));
}
예제 #2
0
/* The do_we_replace logic. Decide, for some existing key, whether it should
 * be replaced with some new contents. Check that names and section
 * extensions match before calling this.
 */
static int replace_if_necessary (struct mandata *newdata,
				 struct mandata *olddata,
				 datum newkey, datum newcont)
{
	/* It's OK to replace ULT_MAN with SO_MAN if the mtime is newer. It
	 * isn't OK to replace a real page (either ULT_MAN or SO_MAN) with a
	 * whatis reference; if the real page really went away then
	 * purge_missing will catch that in time, but a real page that still
	 * exists should always take precedence.
	 */
	if (compare_ids (newdata->id, olddata->id, 1) <= 0 &&
	    newdata->_st_mtime > olddata->_st_mtime) {
		debug ("replace_if_necessary(): newer mtime; replacing\n");
		if (MYDBM_REPLACE (dbf, newkey, newcont))
			gripe_replace_key (MYDBM_DPTR (newkey));
		return 0;
	}

	if (compare_ids (newdata->id, olddata->id, 0) < 0) {
		if (MYDBM_REPLACE (dbf, newkey, newcont))
			gripe_replace_key (MYDBM_DPTR (newkey));
		return 0;
	}

	/* TODO: name fields should be collated with the requested name */

	if (newdata->id == olddata->id) {
		if (STREQ (dash_if_unset (newdata->comp), olddata->comp))
			return 0; /* same file */
		else {
			debug ("ignoring differing compression "
			       "extensions: %s\n", MYDBM_DPTR (newkey));
			return 1; /* differing exts */
		}
	}

	debug ("ignoring differing ids: %s\n", MYDBM_DPTR (newkey));
	return 0;
}
예제 #3
0
PyObject *
TreeEntry_richcompare(PyObject *a, PyObject *b, int op)
{
    PyObject *res;
    TreeEntry *ta, *tb;
    int cmp;

    /* We only support comparing to another tree entry */
    if (!PyObject_TypeCheck(b, &TreeEntryType)) {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    ta = (TreeEntry *) a;
    tb = (TreeEntry *) b;

    /* This is sorting order, if they sort equally, we still need to compare the ids */
    cmp = git_tree_entry_cmp(ta->entry, tb->entry);
    if (cmp == 0)
        cmp = compare_ids(ta, tb);

    switch (op) {
        case Py_LT:
            res = (cmp <= 0) ? Py_True: Py_False;
            break;
        case Py_LE:
            res = (cmp < 0) ? Py_True: Py_False;
            break;
        case Py_EQ:
            res = (cmp == 0) ? Py_True: Py_False;
            break;
        case Py_NE:
            res = (cmp != 0) ? Py_True: Py_False;
            break;
        case Py_GT:
            res = (cmp > 0) ? Py_True: Py_False;
            break;
        case Py_GE:
            res = (cmp >= 0) ? Py_True: Py_False;
            break;
        default:
            PyErr_Format(PyExc_RuntimeError, "Unexpected '%d' op", op);
            return NULL;
    }

    Py_INCREF(res);
    return res;
}