Browse Source

fixed segmentation fault #758 (#762)

pull/768/head
skyformat99 3 years ago
committed by GitHub
parent
commit
586beee871
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/n2n.c

5
src/n2n.c

@ -426,14 +426,15 @@ void resolve_cancel_thread (n2n_resolve_parameter_t *param) {
uint8_t resolve_check (n2n_resolve_parameter_t *param, uint8_t requires_resolution, time_t now) {
uint8_t ret = requires_resolution; /* if trylock fails, it still requires resolution */
#ifdef HAVE_PTHREAD
if(param != NULL) {
n2n_resolve_ip_sock_t *entry, *tmp_entry;
n2n_sock_str_t sock_buf;
// check_interval and last_check do not need to be guarded by the mutex because
// their values get changed and evaluated only here
if((now - param->last_checked > param->check_interval) || (requires_resolution)) {
// try to lock access
if(pthread_mutex_trylock(&param->access) == 0) {
@ -469,7 +470,9 @@ uint8_t resolve_check (n2n_resolve_parameter_t *param, uint8_t requires_resoluti
pthread_mutex_unlock(&param->access);
}
}
}
#endif
return ret;
}

Loading…
Cancel
Save