mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:33:02 +01:00
non-critical thread failures shouldn't be fatal
This commit is contained in:
parent
14dc02ac83
commit
e42d635195
23
src/dns.c
23
src/dns.c
@ -407,12 +407,23 @@ void dns3_lookup(ToxWindow *self, Tox *m, const char *id_bin, const char *addr,
|
|||||||
t_data.m = m;
|
t_data.m = m;
|
||||||
t_data.busy = 1;
|
t_data.busy = 1;
|
||||||
|
|
||||||
if (pthread_attr_init(&dns_thread.attr) != 0)
|
if (pthread_attr_init(&dns_thread.attr) != 0) {
|
||||||
exit_toxic_err("failed in dns3_lookup", FATALERR_THREAD_ATTR);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "Error: DNS thread attr failed to init");
|
||||||
|
memset(&t_data, 0, sizeof(struct thread_data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_attr_setdetachstate(&dns_thread.attr, PTHREAD_CREATE_DETACHED) != 0)
|
if (pthread_attr_setdetachstate(&dns_thread.attr, PTHREAD_CREATE_DETACHED) != 0) {
|
||||||
exit_toxic_err("failed in dns3_lookup", FATALERR_THREAD_ATTR);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "Error: DNS thread attr failed to set");
|
||||||
|
pthread_attr_destroy(&dns_thread.attr);
|
||||||
|
memset(&t_data, 0, sizeof(struct thread_data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_create(&dns_thread.tid, &dns_thread.attr, dns3_lookup_thread, NULL) != 0)
|
if (pthread_create(&dns_thread.tid, &dns_thread.attr, dns3_lookup_thread, NULL) != 0) {
|
||||||
exit_toxic_err("failed in dns3_lookup", FATALERR_THREAD_CREATE);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "Error: DNS thread failed to init");
|
||||||
|
pthread_attr_destroy(&dns_thread.attr);
|
||||||
|
memset(&t_data, 0, sizeof(struct thread_data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,14 +396,22 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
|
|||||||
thrd->self = self;
|
thrd->self = self;
|
||||||
thrd->timestamp = get_unix_time();
|
thrd->timestamp = get_unix_time();
|
||||||
|
|
||||||
if (pthread_attr_init(&thrd->attr) != 0)
|
if (pthread_attr_init(&thrd->attr) != 0) {
|
||||||
exit_toxic_err("failed in groupchat_onGroupNamelistChange", FATALERR_THREAD_ATTR);
|
free(thrd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_attr_setdetachstate(&thrd->attr, PTHREAD_CREATE_DETACHED) != 0)
|
if (pthread_attr_setdetachstate(&thrd->attr, PTHREAD_CREATE_DETACHED) != 0) {
|
||||||
exit_toxic_err("failed in groupchat_onGroupNamelistChange", FATALERR_THREAD_ATTR);
|
pthread_attr_destroy(&thrd->attr);
|
||||||
|
free(thrd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_create(&thrd->tid, &thrd->attr, group_add_wait, (void *) thrd) != 0)
|
if (pthread_create(&thrd->tid, &thrd->attr, group_add_wait, (void *) thrd) != 0) {
|
||||||
exit_toxic_err("failed in groupchat_onGroupNamelistChange", FATALERR_THREAD_CREATE);
|
pthread_attr_destroy(&thrd->attr);
|
||||||
|
free(thrd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user