Minor cleanup: return early on error condition.

This commit is contained in:
iphydf 2018-06-17 19:10:15 +00:00
parent 2f80e2206c
commit a725d73235
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -2063,25 +2063,19 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port,
return -1; return -1;
} }
if (add_ip_port_connection(c, crypt_connection_id, ip_port) == 0) { if (add_ip_port_connection(c, crypt_connection_id, ip_port) != 0) {
if (connected) { return -1;
if (net_family_is_ipv4(ip_port.ip.family)) {
conn->direct_lastrecv_timev4 = unix_time();
} else {
conn->direct_lastrecv_timev6 = unix_time();
}
} else {
if (net_family_is_ipv4(ip_port.ip.family)) {
conn->direct_lastrecv_timev4 = 0;
} else {
conn->direct_lastrecv_timev6 = 0;
}
}
return 0;
} }
return -1; const uint64_t direct_lastrecv_time = connected ? unix_time() : 0;
if (net_family_is_ipv4(ip_port.ip.family)) {
conn->direct_lastrecv_timev4 = direct_lastrecv_time;
} else {
conn->direct_lastrecv_timev6 = direct_lastrecv_time;
}
return 0;
} }