summaryrefslogtreecommitdiff
path: root/ecp/src/ecp/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/src/ecp/core.c')
-rw-r--r--ecp/src/ecp/core.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/ecp/src/ecp/core.c b/ecp/src/ecp/core.c
index 1ba042d..3d4342d 100644
--- a/ecp/src/ecp/core.c
+++ b/ecp/src/ecp/core.c
@@ -202,11 +202,14 @@ static int conn_table_insert(ECPConnection *conn) {
}
}
}
-#else
+
+#else /* ECP_WITH_HTABLE */
+
if (sock->conn_table.size == ECP_MAX_SOCK_CONN) return ECP_ERR_FULL;
sock->conn_table.arr[sock->conn_table.size] = conn;
sock->conn_table.size++;
-#endif
+
+#endif /* ECP_WITH_HTABLE */
return ECP_OK;
}
@@ -231,6 +234,7 @@ static void conn_table_remove(ECPConnection *conn) {
int i;
#ifdef ECP_WITH_HTABLE
+
if (ecp_conn_is_outb(conn)) {
for (i=0; i<ECP_MAX_CONN_KEY; i++) {
if (conn->key[i].valid) {
@@ -247,7 +251,9 @@ static void conn_table_remove(ECPConnection *conn) {
}
}
}
-#else
+
+#else /* ECP_WITH_HTABLE */
+
for (i=0; i<sock->conn_table.size; i++) {
if (conn == sock->conn_table.arr[i]) {
while (i < (sock->conn_table.size-1)) {
@@ -259,7 +265,8 @@ static void conn_table_remove(ECPConnection *conn) {
return;
}
}
-#endif
+
+#endif /* ECP_WITH_HTABLE */
}
static void conn_table_remove_addr(ECPConnection *conn) {
@@ -278,6 +285,7 @@ static ECPConnection *conn_table_search(ECPSocket *sock, unsigned char c_idx, ec
#endif
#ifdef ECP_WITH_HTABLE
+
if (c_public) {
return ecp_ht_search(sock->conn_table.keys, c_public);
} else if (addr) {
@@ -285,7 +293,8 @@ static ECPConnection *conn_table_search(ECPSocket *sock, unsigned char c_idx, ec
} else {
return NULL;
}
-#else
+
+#else /* ECP_WITH_HTABLE */
ECPConnection *conn = NULL;
int i;
@@ -319,14 +328,15 @@ static ECPConnection *conn_table_search(ECPSocket *sock, unsigned char c_idx, ec
}
return NULL;
-#endif
+
+#endif /* ECP_WITH_HTABLE */
}
static void conn_table_expire_inb(ECPSocket *sock, ecp_sts_t to) {
ECPConnection *conn;
ECPConnection *to_remove[ECP_MAX_EXP];
int i, remove_cnt;
- ecp_sts_t access_ts, now = ecp_tm_abstime_ms(0);
+ ecp_sts_t access_ts, now = ecp_tm_get_tick();
#ifdef ECP_WITH_HTABLE
struct hashtable_itr itr;
@@ -407,7 +417,7 @@ static void conn_table_expire_inb(ECPSocket *sock, ecp_sts_t to) {
pthread_mutex_unlock(&conn->mutex);
#endif
- if (now - access_ts > to)) {
+ if (now - access_ts > to) {
to_remove[remove_cnt] = conn;
remove_cnt++;
if (remove_cnt == ECP_MAX_EXP) break;
@@ -2185,7 +2195,7 @@ ssize_t ecp_unpack(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr,
conn->nonce_in = nonce_in;
conn->nonce_map = nonce_map;
if (is_inb) {
- conn->access_ts = ecp_tm_abstime_ms(0);
+ conn->access_ts = ecp_tm_get_tick();
if (addr) conn->remote.addr = *addr;
}