Specify explicit admission policy in existing ETCP constructors
This commit is contained in:
1 parent
091a1dc053
commit
0ff1dc4f66
3 files changed
+11
-11
No files matched your search
@@ -43,7 +43,7 @@ static void owner_cb(struct NODE_CONN_DIRECT* h, enum ncd_event event, void* arg
|
||||
}
|
||||
}
|
||||
static struct ETCP_CONN* ready_conn(struct UTUN_INSTANCE* inst) {
|
||||
struct ETCP_CONN* c = etcp_connection_create(inst,"ncd_lifecycle"); CHECK(c);
|
||||
struct ETCP_CONN* c = etcp_connection_create(inst,"ncd_lifecycle", 0); CHECK(c);
|
||||
c->peer_node_id = 42; c->links_up = 1; etcp_conn_ready(c);
|
||||
queue_set_callback(c->send_input_q,NULL,NULL); // физического линка нет; проверяем lifecycle управляющих отправок
|
||||
return c;
|
||||
@@ -180,7 +180,7 @@ static void subscription_update(struct subscription_case *test, unsigned index,
|
||||
static void subscription_fire(struct subscription_case *test) {
|
||||
switch (test->kind) {
|
||||
case 0: {
|
||||
struct ETCP_CONN *created = etcp_connection_create(test->inst, "nested subscription"); CHECK(created);
|
||||
struct ETCP_CONN *created = etcp_connection_create(test->inst, "nested subscription", 0); CHECK(created);
|
||||
etcp_connection_close(created);
|
||||
break;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ static void subscription_socket(struct ETCP_SOCKET *socket, int event, void *arg
|
||||
static void subscription_cases(struct UTUN_INSTANCE *inst) {
|
||||
for (unsigned kind = 0; kind < 4; kind++) {
|
||||
struct subscription_case test = {.inst = inst, .kind = kind};
|
||||
test.conn = etcp_connection_create(inst, "subscription lifetime"); CHECK(test.conn);
|
||||
test.conn = etcp_connection_create(inst, "subscription lifetime", 0); CHECK(test.conn);
|
||||
if (kind == 2) { test.link = etcp_link_new(test.conn, NULL, NULL, 0); CHECK(test.link); }
|
||||
test.socket.instance = inst;
|
||||
for (unsigned i = 0; i < 3; i++) { test.args[i].test = &test; test.args[i].index = i; }
|
||||
@@ -247,7 +247,7 @@ static void constructor_close_cases(struct UTUN_INSTANCE *inst) {
|
||||
struct create_close_case test = {.status = status};
|
||||
if (!status) etcp_add_new_conn_cbk(inst, cancel_created_connection, &test);
|
||||
etcp_add_conn_status_cbk(inst, observe_created_connection, &test);
|
||||
CHECK(etcp_connection_create(inst, "cancel creation") == NULL);
|
||||
CHECK(etcp_connection_create(inst, "cancel creation", 0) == NULL);
|
||||
CHECK(test.deleted == 1 && test.created == !status && test.published == status);
|
||||
CHECK(!inst->connections->count);
|
||||
if (!status) etcp_remove_new_conn_cbk(inst, cancel_created_connection, &test);
|
||||
@@ -267,7 +267,7 @@ static void cancel_created_link(struct ETCP_CONN *conn, struct ETCP_LINK *link,
|
||||
}
|
||||
static void link_constructor_close_cases(struct UTUN_INSTANCE *inst) {
|
||||
for (unsigned action = 1; action <= 2; action++) {
|
||||
struct ETCP_CONN *conn = etcp_connection_create(inst, "cancel link"); CHECK(conn);
|
||||
struct ETCP_CONN *conn = etcp_connection_create(inst, "cancel link", 0); CHECK(conn);
|
||||
CHECK(etcp_conn_ref_take(conn) == 0);
|
||||
etcp_add_link_status_cbk(inst, cancel_created_link, (void*)(uintptr_t)action);
|
||||
CHECK(etcp_link_new(conn, NULL, NULL, 0) == NULL);
|
||||
@@ -294,7 +294,7 @@ static void close_neighbor(struct ETCP_CONN *conn, struct ETCP_LINK *link, int o
|
||||
}
|
||||
}
|
||||
static void neighbor_close_case(struct UTUN_INSTANCE *inst) {
|
||||
struct ETCP_CONN *conn = etcp_connection_create(inst, "neighbor close"); CHECK(conn);
|
||||
struct ETCP_CONN *conn = etcp_connection_create(inst, "neighbor close", 0); CHECK(conn);
|
||||
CHECK(etcp_conn_ref_take(conn) == 0);
|
||||
CHECK(etcp_link_new(conn, NULL, NULL, 0));
|
||||
struct link_close_case test = {.neighbor = etcp_link_new(conn, NULL, NULL, 0)}; CHECK(test.neighbor);
|
||||
@@ -308,8 +308,8 @@ static void neighbor_close_case(struct UTUN_INSTANCE *inst) {
|
||||
}
|
||||
|
||||
static void registry_index_cases(struct UTUN_INSTANCE *inst) {
|
||||
struct ETCP_CONN *first = etcp_connection_create(inst, "first indexed"); CHECK(first);
|
||||
struct ETCP_CONN *second = etcp_connection_create(inst, "second indexed"); CHECK(second);
|
||||
struct ETCP_CONN *first = etcp_connection_create(inst, "first indexed", 0); CHECK(first);
|
||||
struct ETCP_CONN *second = etcp_connection_create(inst, "second indexed", 0); CHECK(second);
|
||||
struct ll_entry *entry = first->conn_queue_entry, *other = second->conn_queue_entry;
|
||||
first->peer_node_id = second->peer_node_id = 1;
|
||||
size_t allocated = u_get_allocated_count();
|
||||
@@ -344,7 +344,7 @@ int main(void) {
|
||||
inst.connections = queue_new(inst.ua,16,0,8,"test_connections");
|
||||
for (int scenario=0; scenario<4; scenario++) {
|
||||
deleted = victim_called = 0; release_on_delete = scenario == 0;
|
||||
struct ETCP_CONN* c = etcp_connection_create(&inst,"lifecycle"); CHECK(c);
|
||||
struct ETCP_CONN* c = etcp_connection_create(&inst,"lifecycle", 0); CHECK(c);
|
||||
etcp_conn_add_cbk(c,on_delete,NULL,ETCP_CBK_EVENT_DELETE);
|
||||
if (scenario < 2) CHECK(etcp_conn_ref_take(c) == 0);
|
||||
if (scenario == 2) {
|
||||
|
||||
@@ -50,7 +50,7 @@ int main(void) {
|
||||
sock.links_queue = queue_new(ua, 16, 0, LINK_ADDR_KEY_SIZE, "packet_links"); assert(sock.links_queue);
|
||||
sock.socket_id = uasync_add_socket_t(ua, sock.fd, NULL, etcp_link_io_socket_writable, NULL, "packet_test", &sock);
|
||||
assert(sock.socket_id);
|
||||
struct ETCP_CONN* conn = etcp_connection_create(&inst, "packet_test"); assert(conn);
|
||||
struct ETCP_CONN* conn = etcp_connection_create(&inst, "packet_test", 0); assert(conn);
|
||||
conn->peer_node_id = 2; etcp_conn_ready(conn); conn->links_up = 1;
|
||||
struct sockaddr_storage addr = {0}; struct sockaddr_in* ip = (struct sockaddr_in*)&addr;
|
||||
ip->sin_family = AF_INET; ip->sin_addr.s_addr = htonl(INADDR_LOOPBACK); ip->sin_port = htons(1111);
|
||||
|
||||
@@ -89,7 +89,7 @@ static void create(struct fixture* f, int device, int supernode) {
|
||||
topo_node_sqlite_update_rtt(db, node->node_id, (uint16_t)(i + 1));
|
||||
/* История нижнего класса не должна обходить суперузлы. */
|
||||
if (i >= 3) assert(topo_node_sqlite_set_connected(db, "42", node->node_id, 1) == 0);
|
||||
struct ETCP_CONN* conn = f->conns[i] = etcp_connection_create(f->inst, "connect_fixture"); assert(conn);
|
||||
struct ETCP_CONN* conn = f->conns[i] = etcp_connection_create(f->inst, "connect_fixture", 0); assert(conn);
|
||||
conn->peer_node_id = node->node_id;
|
||||
assert(sc_init_ctx(&conn->crypto_ctx, &f->inst->my_keys) == SC_OK);
|
||||
assert(sc_set_peer_public_key(&conn->crypto_ctx, node->public_key, SC_PEER_PUBKEY_BIN) == SC_OK);
|
||||
|
||||
Reference in new issue
Block a user