Index: Makefile =================================================================== RCS file: /usr/cvsroot/asterisk/Makefile,v retrieving revision 1.102 diff -u -r1.102 Makefile --- Makefile 19 Jul 2004 15:52:57 -0000 1.102 +++ Makefile 23 Jul 2004 23:36:11 -0000 @@ -130,6 +130,7 @@ ifeq (${OSARCH},OpenBSD) CFLAGS+=-pthread +LIBS+=-pthread endif #Uncomment this to use the older DSP routines @@ -175,6 +176,9 @@ ifeq (${OSARCH},FreeBSD) LIBS+=-lcrypto endif +ifeq (${OSARCH},OpenBSD) +LIBS+=-lcrypto +endif LIBS+=-lssl OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \ translate.o file.o say.o pbx.o cli.o md5.o term.o \ Index: asterisk.c =================================================================== RCS file: /usr/cvsroot/asterisk/asterisk.c,v retrieving revision 1.107 diff -u -r1.107 asterisk.c --- asterisk.c 18 Jul 2004 18:52:36 -0000 1.107 +++ asterisk.c 23 Jul 2004 23:36:12 -0000 @@ -301,6 +301,9 @@ struct pollfd fds[1]; pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for(;;) { if (ast_socket < 0) @@ -358,6 +361,7 @@ struct sockaddr_un sun; int res; int x; + pthread_attr_t attr; for (x=0;x -1) ? 1 : 0, NULL, &outfd, &ms); + if (!rchan && (outfd < 0) && (ms)) { ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); - return -1; +#ifdef BSD + return 0; +#else + return -1; +#endif } else if (outfd > -1) { /* The FD we were watching has something waiting */ return 1; Index: manager.c =================================================================== RCS file: /usr/cvsroot/asterisk/manager.c,v retrieving revision 1.64 diff -u -r1.64 manager.c --- manager.c 14 Jul 2004 07:44:19 -0000 1.64 +++ manager.c 23 Jul 2004 23:36:15 -0000 @@ -858,6 +858,9 @@ fast->timeout = to; fast->priority = pi; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&th, &attr, fast_originate, fast)) { @@ -1154,6 +1157,9 @@ pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for (;;) { @@ -1322,6 +1328,7 @@ int oldportno = portno; static struct sockaddr_in ba; int x = 1; + pthread_attr_t attr; if (!registered) { /* Register default actions */ ast_manager_register2("Ping", 0, action_ping, "Ping", mandescr_ping); @@ -1421,7 +1428,11 @@ } if (option_verbose) ast_verbose("Asterisk Management interface listening on port %d\n", portno); - pthread_create(&t, NULL, accept_thread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&t, &attr, accept_thread, NULL); } return 0; } Index: pbx.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx.c,v retrieving revision 1.139 diff -u -r1.139 pbx.c --- pbx.c 19 Jul 2004 00:30:39 -0000 1.139 +++ pbx.c 23 Jul 2004 23:36:20 -0000 @@ -834,9 +834,9 @@ int len_len=4; if (strrchr(var,')')) { char cp3[80]; - strncpy(cp3, var, sizeof(cp3) - 1); + strncpy(cp3, &var[len_len], sizeof(cp3) - 1); cp3[len-len_len-1]='\0'; - sprintf(workspace,"%d",(int)strlen(cp3)); + sprintf(workspace,"%d",strlen(cp3)); *ret = workspace; } else { /* length is zero */ @@ -903,7 +903,7 @@ } else *ret = NULL; } else if (c && !strcmp(var, "HINT")) { - if (!ast_get_hint(workspace, workspacelen, c, c->context, c->exten)) + if (!ast_get_hint(workspace, workspacelen - 1, c, c->context, c->exten)) *ret = NULL; else *ret = workspace; @@ -936,12 +936,12 @@ strncpy(workspace, c->name, workspacelen - 1); *ret = workspace; } else if (c && !strcmp(var, "EPOCH")) { - snprintf(workspace, workspacelen, "%u",(int)time(NULL)); + snprintf(workspace, workspacelen -1, "%u",(int)time(NULL)); *ret = workspace; } else if (c && !strcmp(var, "DATETIME")) { thistime=time(NULL); localtime_r(&thistime, &brokentime); - snprintf(workspace, workspacelen, "%02d%02d%04d-%02d:%02d:%02d", + snprintf(workspace, workspacelen -1, "%02d%02d%04d-%02d:%02d:%02d", brokentime.tm_mday, brokentime.tm_mon+1, brokentime.tm_year+1900, @@ -954,7 +954,7 @@ thistime=time(NULL); localtime_r(&thistime, &brokentime); /* 20031130-150612 */ - snprintf(workspace, workspacelen, "%04d%02d%02d-%02d%02d%02d", + snprintf(workspace, workspacelen -1, "%04d%02d%02d-%02d%02d%02d", brokentime.tm_year+1900, brokentime.tm_mon+1, brokentime.tm_mday, @@ -964,10 +964,10 @@ ); *ret = workspace; } else if (c && !strcmp(var, "UNIQUEID")) { - snprintf(workspace, workspacelen, "%s", c->uniqueid); + snprintf(workspace, workspacelen -1, "%s", c->uniqueid); *ret = workspace; } else if (c && !strcmp(var, "HANGUPCAUSE")) { - snprintf(workspace, workspacelen, "%i", c->hangupcause); + snprintf(workspace, workspacelen -1, "%i", c->hangupcause); *ret = workspace; } else if (c && !strcmp(var, "ACCOUNTCODE")) { strncpy(workspace, c->accountcode, workspacelen - 1); @@ -1007,13 +1007,16 @@ } } if (!(*ret)) { - int len=strlen(var); - int len_env=strlen("ENV("); + size_t len=strlen(var); + size_t len_env=strlen("ENV("); if (len > (len_env+1) && !strncasecmp(var,"ENV(",len_env) && !strcmp(var+len-1,")")) { char cp3[80] = ""; - strncpy(cp3, var, sizeof(cp3) - 1); - cp3[len-1]='\0'; - *ret=getenv(cp3+len_env); + size_t count = len - len_env - 1; + if(count >= sizeof(cp3)) + count = sizeof(cp3 - 1); + strncpy(cp3, &var[len_env], count); + cp3[count] = '\0'; + *ret=getenv(cp3); if (*ret) { strncpy(workspace, *ret, workspacelen - 1); *ret = workspace; @@ -1029,7 +1032,7 @@ const char *tmp, *whereweare; int length; char workspace[4096]; - char ltmp[4096], var[4096]; + char ltmp[4096]; char *nextvar, *nextexp; char *vars, *vare; int pos, brackets, needsub, len; @@ -1093,37 +1096,37 @@ } if (brackets) ast_log(LOG_NOTICE, "Error in extension logic (missing '}')\n"); + len = vare - vars - 1; /* Skip totally over variable name */ whereweare += ( len + 3); - - /* Store variable name (and truncate) */ - memset(var, 0, sizeof(var)); - strncpy(var, vars, sizeof(var) - 1); - var[len] = '\0'; - - /* Substitute if necessary */ - if (needsub) { - memset(ltmp, 0, sizeof(ltmp)); - pbx_substitute_variables_helper(c, var, ltmp, sizeof(ltmp) - 1); - vars = ltmp; - } else { - vars = var; + { + /* Store variable name (and truncate) */ + char *var = (char*)alloca(len + 1); + if (var) { + memcpy(var, vars, len); + var[len] = 0; + if (needsub) { + pbx_substitute_variables_helper(c, var, ltmp, sizeof(ltmp) - 1); + vars = ltmp; + } else { + vars = var; + } + } else { + ast_log(LOG_ERROR, "Out of memory\n"); + } } - /* Retrieve variable value */ - workspace[0] = '\0'; - pbx_substitute_variables_temp(c,vars,&cp4, workspace, sizeof(workspace)); + pbx_substitute_variables_temp(c,vars,&cp4, workspace, sizeof(workspace) - 1); if (cp4) { length = strlen(cp4); - if (length > count) - length = count; + if (length >= count) length = count - 1; memcpy(cp2, cp4, length); count -= length; cp2 += length; + *cp2 = 0; } - } else if (nextexp) { /* We have an expression. Find the start and end, and determine if we are going to have to recursively call ourselves on the @@ -1154,21 +1157,23 @@ /* Skip totally over variable name */ whereweare += ( len + 3); - - /* Store variable name (and truncate) */ - memset(var, 0, sizeof(var)); - strncpy(var, vars, sizeof(var) - 1); - var[len] = '\0'; - - /* Substitute if necessary */ - if (needsub) { - memset(ltmp, 0, sizeof(ltmp)); - pbx_substitute_variables_helper(c, var, ltmp, sizeof(ltmp) - 1); - vars = ltmp; - } else { - vars = var; + { + /* Store variable name (and truncate) */ + char *var = (char*)alloca(len + 1); + if (var) { + memcpy(var, vars, len); + var[len] = 0; + /* Substitute if necessary */ + if (needsub) { + pbx_substitute_variables_helper(c, var, ltmp, sizeof(ltmp) - 1); + vars = ltmp; + } else { + vars = var; + } + } else { + ast_log(LOG_ERROR, "Out of memory\n"); + } } - /* Evaluate expression */ cp4 = ast_expr(vars); @@ -1712,12 +1717,12 @@ } -int ast_get_hint(char *hint, int hintsize, struct ast_channel *c, char *context, char *exten) +int ast_get_hint(char *hint, int maxlen, struct ast_channel *c, char *context, char *exten) { struct ast_exten *e; e = ast_hint_extension(c, context, exten); if (e) { - strncpy(hint, ast_get_extension_app(e), hintsize - 1); + strncpy(hint, ast_get_extension_app(e), maxlen); return -1; } return 0; @@ -1935,8 +1940,7 @@ ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name); out: if ((res != AST_PBX_KEEPALIVE) && ast_exists_extension(c, c->context, "h", 1, c->callerid)) { - c->exten[0] = 'h'; - c->exten[1] = '\0'; + strcpy(c->exten, "h"); c->priority = 1; while(ast_exists_extension(c, c->context, c->exten, c->priority, c->callerid)) { if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->callerid))) { @@ -1983,6 +1987,9 @@ /* Start a new thread, and get something handling this channel. */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif if (pthread_create(&t, &attr, pbx_thread, c)) { ast_log(LOG_WARNING, "Failed to create new channel thread\n"); return -1; @@ -3733,7 +3740,7 @@ ext_strncpy(tmp->cidmatch, callerid, sizeof(tmp->cidmatch)); tmp->matchcid = 1; } else { - tmp->cidmatch[0] = '\0'; + strcpy(tmp->cidmatch, ""); tmp->matchcid = 0; } strncpy(tmp->app, application, sizeof(tmp->app)-1); @@ -4038,6 +4045,9 @@ pbx_builtin_setvar( chan, var ); } pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&as->p, &attr, async_wait, as)) { ast_log(LOG_WARNING, "Failed to start async wait\n"); @@ -4108,6 +4118,9 @@ ast_pbx_run_app(tmp); } else { pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) { ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno)); @@ -4150,6 +4163,9 @@ /* Start a new thread, and get something handling this channel. */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif if (pthread_create(&as->p, &attr, async_wait, as)) { ast_log(LOG_WARNING, "Failed to start async wait\n"); free(as); @@ -4249,17 +4265,11 @@ __ast_context_destroy(con,registrar); } -static void wait_for_hangup(struct ast_channel *chan, void *data) +static void wait_for_hangup(struct ast_channel *chan) { int res; struct ast_frame *f; - int waittime; - - if (!data || !strlen(data) || (sscanf(data, "%i", &waittime) != 1) || (waittime < 0)) - waittime = -1; - if (waittime > -1) { - ast_safe_sleep(chan, waittime * 1000); - } else do { + do { res = ast_waitfor(chan, -1); if (res < 0) return; @@ -4284,14 +4294,14 @@ static int pbx_builtin_busy(struct ast_channel *chan, void *data) { ast_indicate(chan, AST_CONTROL_BUSY); - wait_for_hangup(chan, data); + wait_for_hangup(chan); return -1; } static int pbx_builtin_congestion(struct ast_channel *chan, void *data) { ast_indicate(chan, AST_CONTROL_CONGESTION); - wait_for_hangup(chan, data); + wait_for_hangup(chan); return -1; } Index: utils.c =================================================================== RCS file: /usr/cvsroot/asterisk/utils.c,v retrieving revision 1.15 diff -u -r1.15 utils.c --- utils.c 29 Jun 2004 17:54:25 -0000 1.15 +++ utils.c 23 Jul 2004 23:36:20 -0000 @@ -192,12 +192,17 @@ int test_for_thread_safety(void) { + pthread_attr_t attr; ast_mutex_lock(&test_lock2); ast_mutex_lock(&test_lock); lock_count += 1; ast_mutex_lock(&test_lock); lock_count += 1; - pthread_create(&test_thread, NULL, test_thread_body, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&test_thread, &attr, test_thread_body, NULL); usleep(100); if (lock_count != 2) test_errors++; Index: apps/app_qcall.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_qcall.c,v retrieving revision 1.12 diff -u -r1.12 app_qcall.c --- apps/app_qcall.c 14 Jul 2004 07:34:34 -0000 1.12 +++ apps/app_qcall.c 23 Jul 2004 23:36:21 -0000 @@ -155,6 +155,9 @@ may go on and use the buffer */ arg = (void *) strdup(fname); pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&dialer_thread,&attr,qcall_do,arg) == -1) { @@ -369,9 +372,14 @@ int load_module(void) { + pthread_attr_t attr; snprintf(qdir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "qcall"); mkdir(qdir,0760); - pthread_create(&qcall_thread,NULL,qcall,NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&qcall_thread,&attr,qcall,NULL); return 0; } Index: apps/app_rpt.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_rpt.c,v retrieving revision 1.17 diff -u -r1.17 app_rpt.c --- apps/app_rpt.c 14 Jul 2004 07:34:34 -0000 1.17 +++ apps/app_rpt.c 23 Jul 2004 23:36:24 -0000 @@ -1054,6 +1054,9 @@ insque((struct qelem *)tele,(struct qelem *)myrpt->tele.next); ast_mutex_unlock(&myrpt->lock); pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&tele->threadid,&attr,rpt_tele_thread,(void *) tele); return; @@ -1614,6 +1617,9 @@ myrpt->exten[myrpt->cidx] = 0; ast_mutex_unlock(&myrpt->lock); pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *) myrpt); return DC_COMPLETE; @@ -3134,6 +3140,9 @@ myrpt->cidx = 0; myrpt->exten[myrpt->cidx] = 0; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *)myrpt); continue; @@ -3407,6 +3416,7 @@ char *this,*val; struct ast_variable *vp; int i,j,n,longestnode; +pthread_attr_t attr; /* start with blank config */ memset(&rpt_vars,0,sizeof(rpt_vars)); @@ -3539,7 +3549,11 @@ ast_log(LOG_WARNING,"Did not specify ident for node %s\n",rpt_vars[i].name); pthread_exit(NULL); } - pthread_create(&rpt_vars[i].rpt_thread,NULL,rpt,(void *) &rpt_vars[i]); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]); } /* wait for first one to die (should be never) */ pthread_join(rpt_vars[0].rpt_thread,NULL); @@ -3920,7 +3934,12 @@ int load_module(void) { - pthread_create(&rpt_master_thread,NULL,rpt_master,NULL); + pthread_attr_t attr; + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&rpt_master_thread,&attr,rpt_master,NULL); return ast_register_application(app, rpt_exec, synopsis, descrip); } Index: channels/chan_alsa.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v retrieving revision 1.24 diff -u -r1.24 chan_alsa.c --- channels/chan_alsa.c 16 Jul 2004 04:40:54 -0000 1.24 +++ channels/chan_alsa.c 23 Jul 2004 23:36:25 -0000 @@ -977,6 +977,7 @@ int x; struct ast_config *cfg; struct ast_variable *v; + pthread_attr_t attr; res = pipe(sndcmd); if (res) { ast_log(LOG_ERROR, "Unable to create pipe\n"); @@ -1024,7 +1025,11 @@ } ast_destroy(cfg); } - pthread_create(&sthread, NULL, sound_thread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&sthread, &attr, sound_thread, NULL); #ifdef ALSA_MONITOR if (alsa_monitor_start()) { ast_log(LOG_ERROR, "Problem starting Monitoring\n"); Index: channels/chan_h323.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v retrieving revision 1.70 diff -u -r1.70 chan_h323.c --- channels/chan_h323.c 22 Jul 2004 04:24:50 -0000 1.70 +++ channels/chan_h323.c 23 Jul 2004 23:36:27 -0000 @@ -1414,6 +1414,7 @@ static int restart_monitor(void) { + pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; @@ -1431,7 +1432,11 @@ pthread_kill(monitor_thread, SIGURG); } else { /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; Index: channels/chan_iax.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax.c,v retrieving revision 1.64 diff -u -r1.64 chan_iax.c --- channels/chan_iax.c 16 Jul 2004 04:40:54 -0000 1.64 +++ channels/chan_iax.c 23 Jul 2004 23:36:34 -0000 @@ -4548,7 +4548,12 @@ static int start_network_thread(void) { - return pthread_create(&netthreadid, NULL, network_thread, NULL); + pthread_attr_t attr; + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + return pthread_create(&netthreadid, &attr, network_thread, NULL); } static struct iax_context *build_context(char *context) Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.173 diff -u -r1.173 chan_iax2.c --- channels/chan_iax2.c 17 Jul 2004 20:58:00 -0000 1.173 +++ channels/chan_iax2.c 23 Jul 2004 23:36:42 -0000 @@ -4652,6 +4652,7 @@ static void spawn_dp_lookup(int callno, char *context, char *callednum, char *callerid) { pthread_t newthread; + pthread_attr_t attr; struct dpreq_data *dpr; dpr = malloc(sizeof(struct dpreq_data)); if (dpr) { @@ -4661,7 +4662,11 @@ strncpy(dpr->callednum, callednum, sizeof(dpr->callednum) - 1); if (callerid) dpr->callerid = strdup(callerid); - if (pthread_create(&newthread, NULL, dp_lookup_thread, dpr)) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&newthread, &attr, dp_lookup_thread, dpr)) { ast_log(LOG_WARNING, "Unable to start lookup thread!\n"); } } else @@ -4698,6 +4703,7 @@ struct iax_dual *d; struct ast_channel *chan1m, *chan2m; pthread_t th; + pthread_attr_t attr; chan1m = ast_channel_alloc(0); chan2m = ast_channel_alloc(0); if (chan2m && chan1m) { @@ -4739,7 +4745,11 @@ memset(d, 0, sizeof(*d)); d->chan1 = chan1m; d->chan2 = chan2m; - if (!pthread_create(&th, NULL, iax_park_thread, d)) + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (!pthread_create(&th, &attr, iax_park_thread, d)) return 0; free(d); } @@ -6096,7 +6106,12 @@ static int start_network_thread(void) { - return pthread_create(&netthreadid, NULL, network_thread, NULL); + pthread_attr_t attr; + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + return pthread_create(&netthreadid, &attr, network_thread, NULL); } static struct iax2_context *build_context(char *context) Index: channels/chan_mgcp.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v retrieving revision 1.61 diff -u -r1.61 chan_mgcp.c --- channels/chan_mgcp.c 17 Jul 2004 20:58:00 -0000 1.61 +++ channels/chan_mgcp.c 23 Jul 2004 23:36:47 -0000 @@ -2716,6 +2716,9 @@ pthread_t t; pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* Off hook / answer */ @@ -3266,6 +3269,9 @@ { pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* If we're supposed to be stopped -- stay stopped */ Index: channels/chan_modem.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_modem.c,v retrieving revision 1.25 diff -u -r1.25 chan_modem.c --- channels/chan_modem.c 16 Jul 2004 04:40:54 -0000 1.25 +++ channels/chan_modem.c 23 Jul 2004 23:36:48 -0000 @@ -654,6 +654,7 @@ static int restart_monitor() { + pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; @@ -673,7 +674,11 @@ pthread_join(monitor_thread, NULL); } /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; Index: channels/chan_oss.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v retrieving revision 1.29 diff -u -r1.29 chan_oss.c --- channels/chan_oss.c 16 Jul 2004 04:40:54 -0000 1.29 +++ channels/chan_oss.c 23 Jul 2004 23:36:49 -0000 @@ -970,6 +970,7 @@ int x; struct ast_config *cfg; struct ast_variable *v; + pthread_attr_t attr; res = pipe(sndcmd); if (res) { ast_log(LOG_ERROR, "Unable to create pipe\n"); @@ -1011,7 +1012,11 @@ } ast_destroy(cfg); } - pthread_create(&sthread, NULL, sound_thread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&sthread, &attr, sound_thread, NULL); return 0; } Index: channels/chan_phone.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_phone.c,v retrieving revision 1.32 diff -u -r1.32 chan_phone.c --- channels/chan_phone.c 16 Jul 2004 04:40:54 -0000 1.32 +++ channels/chan_phone.c 23 Jul 2004 23:36:51 -0000 @@ -943,6 +943,7 @@ static int restart_monitor() { + pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; @@ -962,7 +963,11 @@ #endif } /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.460 diff -u -r1.460 chan_sip.c --- channels/chan_sip.c 22 Jul 2004 23:16:40 -0000 1.460 +++ channels/chan_sip.c 23 Jul 2004 23:37:01 -0000 @@ -6721,6 +6721,7 @@ struct sip_dual *d; struct ast_channel *chan1m, *chan2m; pthread_t th; + pthread_attr_t attr; chan1m = ast_channel_alloc(0); chan2m = ast_channel_alloc(0); if (chan2m && chan1m) { @@ -6767,7 +6768,11 @@ copy_request(&d->req, req); d->chan1 = chan1m; d->chan2 = chan2m; - if (!pthread_create(&th, NULL, sip_park_thread, d)) + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (!pthread_create(&th, &attr, sip_park_thread, d)) return 0; free(d); } @@ -7618,6 +7623,9 @@ pthread_kill(monitor_thread, SIGURG); } else { pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* Start a new monitor */ if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { Index: channels/chan_skinny.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v retrieving revision 1.52 diff -u -r1.52 chan_skinny.c --- channels/chan_skinny.c 17 Jul 2004 20:58:00 -0000 1.52 +++ channels/chan_skinny.c 23 Jul 2004 23:37:04 -0000 @@ -1836,6 +1836,7 @@ time_t timer; struct tm *cmtime; pthread_t t; + pthread_attr_t attr; if ( (!s->device) && (req->e != REGISTER_MESSAGE && req->e != ALARM_MESSAGE)) { ast_log(LOG_WARNING, "Client sent message #%d without first registering.\n", req->e); @@ -2113,7 +2114,11 @@ c = skinny_new(sub, AST_STATE_DOWN); if(c) { /* start switch */ - if (pthread_create(&t, NULL, skinny_ss, c)) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&t, &attr, skinny_ss, c)) { ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); ast_hangup(c); } @@ -2374,6 +2379,9 @@ pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for (;;) { @@ -2403,7 +2411,7 @@ sessions = s; ast_mutex_unlock(&sessionlock); - if (pthread_create(&tcp_thread, NULL, skinny_session, s)) { + if (pthread_create(&tcp_thread, &attr, skinny_session, s)) { destroy_session(s); } } @@ -2444,6 +2452,7 @@ static int restart_monitor(void) { + pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; @@ -2461,7 +2470,11 @@ pthread_kill(monitor_thread, SIGURG); } else { /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; @@ -2523,6 +2536,7 @@ char iabuf[INET_ADDRSTRLEN]; struct skinny_device *d; int oldport = ntohs(bindaddr.sin_port); + pthread_attr_t attr; #if 0 hp = ast_gethostbyname(ourhost, &ahp); @@ -2649,7 +2663,11 @@ ast_verbose(VERBOSE_PREFIX_2 "Skinny listening on %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port)); - pthread_create(&accept_t,NULL, accept_thread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&accept_t, &attr, accept_thread, NULL); } } ast_mutex_unlock(&netlock); Index: channels/chan_vofr.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_vofr.c,v retrieving revision 1.18 diff -u -r1.18 chan_vofr.c --- channels/chan_vofr.c 16 Jul 2004 04:40:54 -0000 1.18 +++ channels/chan_vofr.c 23 Jul 2004 23:37:05 -0000 @@ -997,6 +997,7 @@ static int restart_monitor(void) { + pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; @@ -1014,7 +1015,11 @@ pthread_kill(monitor_thread, SIGURG); } else { /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; Index: channels/chan_vpb.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v retrieving revision 1.32 diff -u -r1.32 chan_vpb.c --- channels/chan_vpb.c 16 Jul 2004 04:40:54 -0000 1.32 +++ channels/chan_vpb.c 23 Jul 2004 23:37:07 -0000 @@ -912,6 +912,7 @@ static int restart_monitor(void) { + pthread_attr_t attr; int error = 0; /* If we're supposed to be stopped -- stay stopped */ @@ -942,7 +943,11 @@ vpb_put_event(&e); } else { /* Start a new monitor */ - int pid = pthread_create(&monitor_thread, NULL, do_monitor, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + int pid = pthread_create(&monitor_thread, &attr, do_monitor, NULL); if (option_verbose > 3) ast_verbose(VERBOSE_PREFIX_4 "Created new monitor thread %d\n",pid); if (pid < 0) { @@ -1204,6 +1209,7 @@ char *s = strrchr(dest, '/'); char dialstring[254] = ""; int tmp = 0; + pthread_attr_t attr; if (option_verbose > 3) ast_verbose("%s: LOCKING in call \n", p->dev); ast_mutex_lock(&p->lock); @@ -1287,7 +1293,11 @@ } if (!p->readthread){ - pthread_create(&p->readthread, NULL, do_chanreads, (void *)p); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&p->readthread, &attr, do_chanreads, (void *)p); } tmp = ast_mutex_unlock(&p->lock); @@ -1394,6 +1404,7 @@ VPB_EVENT je; int ret; int res = 0; + pthread_attr_t attr; if (option_verbose > 3) ast_verbose("%s: LOCKING in answer \n", p->dev); ast_mutex_lock(&p->lock); @@ -1423,7 +1434,11 @@ if( !p->readthread ){ // res = ast_mutex_unlock(&p->lock); // ast_verbose("%s: unLOCKING in answer [%d]\n", p->dev,res); - pthread_create(&p->readthread, NULL, do_chanreads, (void *)p); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&p->readthread, &attr, do_chanreads, (void *)p); } else { if(option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "%s: Record thread already running!!\n",p->dev); Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.303 diff -u -r1.303 chan_zap.c --- channels/chan_zap.c 19 Jul 2004 16:00:40 -0000 1.303 +++ channels/chan_zap.c 23 Jul 2004 23:37:19 -0000 @@ -3011,6 +3011,9 @@ pthread_attr_t attr; struct ast_channel *chan; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); index = zt_get_index(ast, p, 0); p->subs[index].f.frametype = AST_FRAME_NULL; @@ -5215,6 +5218,9 @@ pthread_attr_t attr; struct ast_channel *chan; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (i->radio) return 0; /* Handle an event on a given channel for the monitor thread. */ @@ -5601,6 +5607,9 @@ { pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) @@ -6827,6 +6836,9 @@ pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); gettimeofday(&lastidle, NULL); @@ -6902,7 +6914,7 @@ idle = zt_request("Zap", AST_FORMAT_ULAW, idlen); if (idle) { pri->pvts[nextidle]->isidlecall = 1; - if (pthread_create(&p, NULL, do_idle_thread, idle)) { + if (pthread_create(&p, &attr, do_idle_thread, idle)) { ast_log(LOG_WARNING, "Unable to start new thread for idle channel '%s'\n", idle->name); zt_hangup(idle); } @@ -7664,6 +7676,7 @@ ZT_BUFFERINFO bi; struct zt_spaninfo si; int i; + pthread_attr_t attr; for (i=0;idchannels[i]) @@ -7728,7 +7741,12 @@ /* Assume primary is the one we use */ pri->pri = pri->dchans[0]; pri->resetpos = -1; - if (pthread_create(&pri->master, NULL, pri_dchannel, pri)) { + + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&pri->master, &attr, pri_dchannel, pri)) { for (i=0;idchannels[i]) break; Index: include/asterisk/lock.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/lock.h,v retrieving revision 1.22 diff -u -r1.22 lock.h --- include/asterisk/lock.h 22 Jun 2004 19:53:36 -0000 1.22 +++ include/asterisk/lock.h 23 Jul 2004 23:37:20 -0000 @@ -22,6 +22,8 @@ #define AST_PTHREADT_NULL (pthread_t) -1 #define AST_PTHREADT_STOP (pthread_t) -2 +#define PTHREAD_ATTR_STACKSIZE 1048576 + #ifdef __APPLE__ /* Provide the Linux initializers for MacOS X */ #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE @@ -38,6 +40,13 @@ #endif #endif /* BSD */ +/* Assuming *BSD distributions w/native threads */ +#ifdef BSD +#define pthread_attr_setstacksize(x, y) pthread_attr_setstacksize(x, y) +#else +#define pthread_attr_setstacksize(x, y) /* Linux uses clone() */ +#endif + /* From now on, Asterisk REQUIRES Recursive (not error checking) mutexes and will not run without them. */ #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP Index: include/asterisk/module.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/module.h,v retrieving revision 1.10 diff -u -r1.10 module.h --- include/asterisk/module.h 9 Jun 2004 01:45:08 -0000 1.10 +++ include/asterisk/module.h 23 Jul 2004 23:37:20 -0000 @@ -158,7 +158,7 @@ #define LOCAL_USER_ADD(u) { \ \ - if (!(u=malloc(sizeof(struct localuser)))) { \ + if (!(u=(struct localuser *)malloc(sizeof(struct localuser)))) { \ ast_log(LOG_WARNING, "Out of memory\n"); \ return -1; \ } \ Index: pbx/pbx_gtkconsole.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_gtkconsole.c,v retrieving revision 1.14 diff -u -r1.14 pbx_gtkconsole.c --- pbx/pbx_gtkconsole.c 14 Jul 2004 13:57:15 -0000 1.14 +++ pbx/pbx_gtkconsole.c 23 Jul 2004 23:37:21 -0000 @@ -349,6 +349,7 @@ GtkWidget *sw; GtkWidget *bbox, *hbbox, *add, *removew, *reloadw; char *modtitles[3] = { "Module", "Description", "Use Count" }; + pthread_attr_t attr; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); statusbar = gtk_statusbar_new(); @@ -450,7 +451,11 @@ gtk_container_add(GTK_CONTAINER(window), hbox); gtk_window_set_title(GTK_WINDOW(window), "Asterisk Console"); gtk_widget_grab_focus(cli); - pthread_create(&console_thread, NULL, consolethread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&console_thread, &attr, consolethread, NULL); /* XXX Okay, seriously fix me! XXX */ usleep(100000); ast_register_verbose(verboser); Index: pbx/pbx_kdeconsole_main.cc =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_kdeconsole_main.cc,v retrieving revision 1.3 diff -u -r1.3 pbx_kdeconsole_main.cc --- pbx/pbx_kdeconsole_main.cc 22 Jun 2004 18:49:00 -0000 1.3 +++ pbx/pbx_kdeconsole_main.cc 23 Jul 2004 23:37:21 -0000 @@ -64,7 +64,12 @@ int load_module(void) { pthread_t t; - pthread_create(&t, NULL, kdemain, NULL); + pthread_attr_t attr; + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&t, &attr, kdemain, NULL); return 0; } Index: pbx/pbx_spool.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_spool.c,v retrieving revision 1.15 diff -u -r1.15 pbx_spool.c --- pbx/pbx_spool.c 14 Jul 2004 13:57:15 -0000 1.15 +++ pbx/pbx_spool.c 23 Jul 2004 23:37:21 -0000 @@ -252,6 +252,9 @@ pthread_t t; pthread_attr_t attr; pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&t,&attr,attempt_thread, o) == -1) { ast_log(LOG_WARNING, "Unable to create thread :(\n"); @@ -381,6 +384,9 @@ return 0; } pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (pthread_create(&thread,&attr,scan_thread, NULL) == -1) { ast_log(LOG_WARNING, "Unable to create thread :(\n"); Index: pbx/pbx_wilcalu.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_wilcalu.c,v retrieving revision 1.16 diff -u -r1.16 pbx_wilcalu.c --- pbx/pbx_wilcalu.c 14 Jul 2004 13:57:15 -0000 1.16 +++ pbx/pbx_wilcalu.c 23 Jul 2004 23:37:21 -0000 @@ -57,6 +57,7 @@ static void *autodial(void *ignore) { pthread_t dialstring_thread; + pthread_attr_t attr; char * sendbufptr=sendbuf; int fd=open(dialfile,O_RDONLY|O_NONBLOCK); int flags = fcntl(fd, F_GETFL); @@ -98,7 +99,11 @@ /* if & then string is complete */ if(buf[x]=='&'){ if(NULL!=(pass=(void *)strdup(sendbuf))){ - pthread_create(&dialstring_thread, NULL, dialstring, pass); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&dialstring_thread, &attr, dialstring, pass); sendbufptr=sendbuf; memset(sendbuf, 0, 257); } @@ -127,10 +132,16 @@ static void *snooze_alarm(void *pass) { pthread_t dialstring_thread; + pthread_attr_t attr; struct alarm_data *data = (struct alarm_data *) pass; sleep(data->snooze_len); - pthread_create(&dialstring_thread, NULL, dialstring, data->dialstr); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&dialstring_thread, &attr, dialstring, data->dialstr); + /* dialstring will free data->dialstr */ free(pass); pthread_exit(NULL); @@ -140,6 +151,7 @@ static void set_snooze_alarm(char *dialstr, int snooze_len) { pthread_t snooze_alarm_thread; + pthread_attr_t attr; struct alarm_data *pass; ast_log(LOG_DEBUG, "Answered: Snooze Requested\n"); @@ -153,7 +165,11 @@ pthread_exit(NULL); } pass->snooze_len=snooze_len; - pthread_create(&snooze_alarm_thread,NULL,snooze_alarm,pass); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&snooze_alarm_thread, &attr, snooze_alarm, pass); } static void *dialstring(void *string) @@ -258,6 +274,7 @@ int load_module(void) { int val; + pthread_attr_t attr; snprintf((char *)dialfile, sizeof(dialfile), "%s/%s", ast_config_AST_RUN_DIR, "autodial.ctl"); if((val=mkfifo(dialfile, 0700))) { @@ -266,7 +283,11 @@ return 0; } } - pthread_create(&autodialer_thread, NULL, autodial, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&autodialer_thread, &attr, autodial, NULL); return 0; } Index: res/res_adsi.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_adsi.c,v retrieving revision 1.9 diff -u -r1.9 res_adsi.c --- res/res_adsi.c 14 Jul 2004 13:57:15 -0000 1.9 +++ res/res_adsi.c 23 Jul 2004 23:37:22 -0000 @@ -727,8 +727,7 @@ int adsi_available(struct ast_channel *chan) { int cpe = chan->adsicpe & 0xff; - if ((cpe == AST_ADSI_AVAILABLE) || - (cpe == AST_ADSI_UNKNOWN)) + if (cpe == AST_ADSI_AVAILABLE) return 1; return 0; } Index: res/res_features.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_features.c,v retrieving revision 1.1 diff -u -r1.1 res_features.c --- res/res_features.c 17 Jul 2004 20:58:01 -0000 1.1 +++ res/res_features.c 23 Jul 2004 23:37:23 -0000 @@ -694,6 +694,7 @@ char exten[AST_MAX_EXTENSION]; struct ast_config *cfg; struct ast_variable *var; + pthread_attr_t attr; ast_cli_register(&showparked); @@ -740,7 +741,11 @@ snprintf(exten, sizeof(exten), "%d", x); ast_add_extension2(con, 1, exten, 1, NULL, parkedcall, strdup(exten), free, registrar); } - pthread_create(&parking_thread, NULL, do_parking_thread, NULL); + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + pthread_create(&parking_thread, &attr, do_parking_thread, NULL); res = ast_register_application(parkedcall, park_exec, synopsis, descrip); if (!res) { ast_manager_register( "ParkedCalls", 0, manager_parking_status, "List parked calls" ); Index: res/res_musiconhold.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v retrieving revision 1.36 diff -u -r1.36 res_musiconhold.c --- res/res_musiconhold.c 17 Jul 2004 20:12:28 -0000 1.36 +++ res/res_musiconhold.c 23 Jul 2004 23:37:24 -0000 @@ -508,6 +508,7 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs) { struct mohclass *moh; + pthread_attr_t attr; #ifdef ZAPATA_MOH int x; #endif @@ -548,7 +549,11 @@ #else moh->pseudofd = -1; #endif - if (pthread_create(&moh->thread, NULL, monmp3thread, moh)) { + pthread_attr_init(&attr); +#ifdef PTHREAD_ATTR_STACKSIZE + pthread_attr_setstacksize(&attr, PTHREAD_ATTR_STACKSIZE); +#endif + if (pthread_create(&moh->thread, &attr, monmp3thread, moh)) { ast_log(LOG_WARNING, "Unable to create moh...\n"); if (moh->pseudofd > -1) close(moh->pseudofd);