summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/main.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-09-19 17:47:26 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-09-19 18:46:13 +0200
commit1dcef3957393c0500b81d93ffacf573e78be9a51 (patch)
treecf29abf695c1d53251560433441c29af57333e4b /src/ipcpd/normal/main.c
parent115431af51795dfd583e24a051a7749c58a900b3 (diff)
downloadouroboros-1dcef3957393c0500b81d93ffacf573e78be9a51.tar.gz
ouroboros-1dcef3957393c0500b81d93ffacf573e78be9a51.zip
ipcpd: Enroll DHT when creating dt connection
The DHT will now enroll or sync when a data transfer connection is added. This avoids the need to create a temporary data transfer connection during enrollment (and speeds it up considerably). The notifier system was modified to take an opaque pointer to the object that registers as a parameter.
Diffstat (limited to 'src/ipcpd/normal/main.c')
-rw-r--r--src/ipcpd/normal/main.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index e6dd6717..6cfea4bc 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -182,29 +182,18 @@ static int bootstrap_components(void)
return 0;
}
-static int enroll_components(uint64_t peer)
-{
- if (dir_enroll(peer)) {
- log_err("Failed to enroll directory.");
- return -1;
- }
-
- return 0;
-}
-
static int normal_ipcp_enroll(const char * dst,
struct dif_info * info)
{
- struct conn er_conn;
- struct conn dt_conn;
+ struct conn conn;
- if (connmgr_alloc(AEID_ENROLL, dst, NULL, &er_conn)) {
+ if (connmgr_alloc(AEID_ENROLL, dst, NULL, &conn)) {
log_err("Failed to get connection.");
goto fail_er_flow;
}
/* Get boot state from peer. */
- if (enroll_boot(&er_conn)) {
+ if (enroll_boot(&conn)) {
log_err("Failed to get boot information.");
goto fail_enroll_boot;
}
@@ -219,29 +208,15 @@ static int normal_ipcp_enroll(const char * dst,
goto fail_dt_start;
}
- if (connmgr_alloc(AEID_DT, dst, NULL, &dt_conn)) {
- log_err("Failed to create a data transfer flow.");
- goto fail_dt_flow;
- }
-
if (start_components()) {
log_err("Failed to start components.");
goto fail_start_comp;
}
- if (enroll_components(dt_conn.conn_info.addr)) {
- enroll_done(&er_conn, -1);
- log_err("Failed to enroll components.");
- goto fail_enroll_comp;
- }
-
- if (enroll_done(&er_conn, 0))
+ if (enroll_done(&conn, 0))
log_warn("Failed to confirm enrollment with peer.");
- if (connmgr_dealloc(AEID_DT, &dt_conn))
- log_warn("Failed to deallocate data transfer flow.");
-
- if (connmgr_dealloc(AEID_ENROLL, &er_conn))
+ if (connmgr_dealloc(AEID_ENROLL, &conn))
log_warn("Failed to deallocate enrollment flow.");
log_info("Enrolled with %s.", dst);
@@ -251,16 +226,12 @@ static int normal_ipcp_enroll(const char * dst,
return 0;
- fail_enroll_comp:
- stop_components();
fail_start_comp:
- connmgr_dealloc(AEID_DT, &dt_conn);
- fail_dt_flow:
dt_stop();
fail_dt_start:
finalize_components();
fail_enroll_boot:
- connmgr_dealloc(AEID_ENROLL, &er_conn);
+ connmgr_dealloc(AEID_ENROLL, &conn);
fail_er_flow:
return -1;
}