#! /bin/sh /usr/share/dpatch/dpatch-run ## pbxspool_pthread_ret.dpatch by Tzafrir Cohen ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Incorrect check for an error returned from ast_pthread_create @DPATCH@ diff -urNad asterisk/pbx/pbx_spool.c /tmp/dpep.CsmL2r/asterisk/pbx/pbx_spool.c --- asterisk/pbx/pbx_spool.c 2006-01-06 00:40:52.000000000 +0200 +++ /tmp/dpep.CsmL2r/asterisk/pbx/pbx_spool.c 2006-01-07 01:46:23.000000000 +0200 @@ -289,9 +289,11 @@ { pthread_t t; pthread_attr_t attr; + int ret; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (ast_pthread_create(&t,&attr,attempt_thread, o) == -1) { + if ((ret = ast_pthread_create(&t,&attr,attempt_thread, o)) != 0) { + ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret); ast_log(LOG_WARNING, "Unable to create thread :(\n"); free_outgoing(o); } @@ -413,6 +415,7 @@ { pthread_t thread; pthread_attr_t attr; + int ret; snprintf(qdir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing"); if (mkdir(qdir, 0700) && (errno != EEXIST)) { ast_log(LOG_WARNING, "Unable to create queue directory %s -- outgoing spool disabled\n", qdir); @@ -420,8 +423,8 @@ } pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (ast_pthread_create(&thread,&attr,scan_thread, NULL) == -1) { - ast_log(LOG_WARNING, "Unable to create thread :(\n"); + if ((ret = ast_pthread_create(&thread,&attr,scan_thread, NULL)) != 0) { + ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret); return -1; } return 0;