summaryrefslogtreecommitdiff
path: root/ecp/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/src')
-rw-r--r--ecp/src/ecp/core.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ecp/src/ecp/core.c b/ecp/src/ecp/core.c
index 3e4aae1..69743fe 100644
--- a/ecp/src/ecp/core.c
+++ b/ecp/src/ecp/core.c
@@ -1091,36 +1091,36 @@ int ecp_conn_insert_gc(ECPConnection *conn) {
ECPSocket *sock = conn->sock;
int rv = ECP_OK;
- rv = ecp_conn_refcount_inc(conn);
- if (rv) return rv;
-
#ifdef ECP_WITH_PTHREAD
pthread_mutex_lock(&sock->conn_table.mutex_gc);
#endif
+ rv = ecp_conn_refcount_inc(conn);
+ if (!rv) {
#ifdef ECP_WITH_HTABLE
- rv = ecp_ht_insert(sock->conn_table.keys_gc, &conn->remote.key_perma.public, conn);
+ rv = ecp_ht_insert(sock->conn_table.keys_gc, &conn->remote.key_perma.public, conn);
+ if (rv) ecp_conn_refcount_dec(conn);
#else /* ECP_WITH_HTABLE */
#ifdef ECP_WITH_PTHREAD
- pthread_mutex_lock(&conn->mutex);
+ pthread_mutex_lock(&conn->mutex);
#endif
- _ecp_conn_push_gct(conn);
+ _ecp_conn_push_gct(conn);
#ifdef ECP_WITH_PTHREAD
- pthread_mutex_unlock(&conn->mutex);
+ pthread_mutex_unlock(&conn->mutex);
#endif
#endif /* ECP_WITH_HTABLE */
+ }
#ifdef ECP_WITH_PTHREAD
pthread_mutex_unlock(&sock->conn_table.mutex_gc);
#endif
- if (rv) ecp_conn_refcount_dec(conn);
return rv;
}