mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Add a new API call for creating detached threads. Then, go replace all of the
places in the code where the same block of code for creating detached threads was replicated. (patch from bbryant) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@65968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4514,12 +4514,8 @@ static void *accept_thread(void *ignore)
|
||||
struct skinnysession *s;
|
||||
struct protoent *p;
|
||||
int arg = 1;
|
||||
pthread_attr_t attr;
|
||||
pthread_t tcp_thread;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
for (;;) {
|
||||
sinlen = sizeof(sin);
|
||||
as = accept(skinnysock, (struct sockaddr *)&sin, &sinlen);
|
||||
@@ -4544,14 +4540,13 @@ static void *accept_thread(void *ignore)
|
||||
sessions = s;
|
||||
ast_mutex_unlock(&sessionlock);
|
||||
|
||||
if (ast_pthread_create(&tcp_thread, &attr, skinny_session, s)) {
|
||||
if (ast_pthread_create_detached(&tcp_thread, NULL, skinny_session, s)) {
|
||||
destroy_session(s);
|
||||
}
|
||||
}
|
||||
if (skinnydebug)
|
||||
ast_verbose("killing accept thread\n");
|
||||
close(as);
|
||||
pthread_attr_destroy(&attr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user