https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49636 | kpfleming | 2007-01-05 11:09:00 -0600 (Fri, 05 Jan 2007) | 10 lines
Merged revisions 49635 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r49635 | kpfleming | 2007-01-05 10:56:40 -0600 (Fri, 05 Jan 2007) | 2 lines
ensure that threads which are supposed to be detached (because we aren't going to wait on them) are created properly
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49637
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
{
pthread_t newthread;
struct dpreq_data *dpr;
+ pthread_attr_t attr;
if (!(dpr = ast_calloc(1, sizeof(*dpr))))
return;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
dpr->callno = callno;
ast_copy_string(dpr->context, context, sizeof(dpr->context));
ast_copy_string(dpr->callednum, callednum, sizeof(dpr->callednum));
if (callerid)
dpr->callerid = ast_strdup(callerid);
- if (ast_pthread_create(&newthread, NULL, dp_lookup_thread, dpr)) {
+ if (ast_pthread_create(&newthread, &attr, dp_lookup_thread, dpr)) {
ast_log(LOG_WARNING, "Unable to start lookup thread!\n");
}
}
return -1;
}
if ((d = ast_calloc(1, sizeof(*d)))) {
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
d->chan1 = chan1m;
d->chan2 = chan2m;
- if (!ast_pthread_create_background(&th, NULL, iax_park_thread, d))
+ if (!ast_pthread_create_background(&th, &attr, iax_park_thread, d))
return 0;
free(d);
}
return -1;
}
if ((d = ast_calloc(1, sizeof(*d)))) {
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
/* Save original request for followup */
copy_request(&d->req, req);
d->chan1 = transferee; /* Transferee */
d->chan2 = transferer; /* Transferer */
d->seqno = seqno;
- if (ast_pthread_create_background(&th, NULL, sip_park_thread, d) < 0) {
+ if (ast_pthread_create_background(&th, &attr, sip_park_thread, d) < 0) {
/* Could not start thread */
free(d); /* We don't need it anymore. If thread is created, d will be free'd
by sip_park_thread() */
struct ast_hostent ahp;
struct hostent *hp;
static int skinnysock = -1;
-static pthread_t tcp_thread;
static pthread_t accept_t;
static char context[AST_MAX_CONTEXT] = "default";
static char language[MAX_LANGUAGE] = "";
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);
sessions = s;
ast_mutex_unlock(&sessionlock);
- if (ast_pthread_create(&tcp_thread, NULL, skinny_session, s)) {
+ if (ast_pthread_create(&tcp_thread, &attr, skinny_session, s)) {
destroy_session(s);
}
}
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
- if (tcp_thread && (tcp_thread != AST_PTHREADT_STOP)) {
- pthread_cancel(tcp_thread);
- pthread_kill(tcp_thread, SIGURG);
- pthread_join(tcp_thread, NULL);
- }
- tcp_thread = AST_PTHREADT_STOP;
-
ast_mutex_lock(&netlock);
if (accept_t && (accept_t != AST_PTHREADT_STOP)) {
pthread_cancel(accept_t);