All of the res/ stuff (other than res_jabber) from the RSW branch.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@137028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Sean Bright 17 years ago
parent b7571f835d
commit 357bf3e90b

@ -571,7 +571,7 @@ void reset_argcount(yyscan_t yyscanner )
/* used elsewhere, but some local vars */ /* used elsewhere, but some local vars */
struct pval *ael2_parse(char *filename, int *errors) struct pval *ael2_parse(char *filename, int *errors)
{ {
struct pval *pval; struct pval *pvalue;
struct parse_io *io; struct parse_io *io;
char *buffer; char *buffer;
struct stat stats; struct stat stats;
@ -610,14 +610,14 @@ struct pval *ael2_parse(char *filename, int *errors)
ael_yyparse(io); ael_yyparse(io);
pval = io->pval; pvalue = io->pval;
*errors = io->syntax_error_count; *errors = io->syntax_error_count;
ael_yylex_destroy(io->scanner); ael_yylex_destroy(io->scanner);
free(buffer); free(buffer);
free(io); free(io);
return pval; return pvalue;
} }
static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create) static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create)

@ -3003,7 +3003,7 @@ void reset_argcount(yyscan_t yyscanner )
/* used elsewhere, but some local vars */ /* used elsewhere, but some local vars */
struct pval *ael2_parse(char *filename, int *errors) struct pval *ael2_parse(char *filename, int *errors)
{ {
struct pval *pval; struct pval *pvalue;
struct parse_io *io; struct parse_io *io;
char *buffer; char *buffer;
struct stat stats; struct stat stats;
@ -3042,14 +3042,14 @@ struct pval *ael2_parse(char *filename, int *errors)
ael_yyparse(io); ael_yyparse(io);
pval = io->pval; pvalue = io->pval;
*errors = io->syntax_error_count; *errors = io->syntax_error_count;
ael_yylex_destroy(io->scanner); ael_yylex_destroy(io->scanner);
free(buffer); free(buffer);
free(io); free(io);
return pval; return pvalue;
} }
static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create) static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create)

@ -114,7 +114,7 @@ static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, in
} }
static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remainder) static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remain)
{ {
/* Sends carefully on a full duplex channel by using reading for /* Sends carefully on a full duplex channel by using reading for
timing */ timing */
@ -124,14 +124,14 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l
/* Zero out our outgoing frame */ /* Zero out our outgoing frame */
memset(&outf, 0, sizeof(outf)); memset(&outf, 0, sizeof(outf));
if (remainder && *remainder) { if (remain && *remain) {
amt = len; amt = len;
/* Send remainder if provided */ /* Send remainder if provided */
if (amt > *remainder) if (amt > *remain)
amt = *remainder; amt = *remain;
else else
*remainder = *remainder - amt; *remain = *remain - amt;
outf.frametype = AST_FRAME_VOICE; outf.frametype = AST_FRAME_VOICE;
outf.subclass = AST_FORMAT_ULAW; outf.subclass = AST_FORMAT_ULAW;
outf.data.ptr = buf; outf.data.ptr = buf;
@ -170,8 +170,8 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l
/* Send no more than they sent us */ /* Send no more than they sent us */
if (amt > inf->datalen) if (amt > inf->datalen)
amt = inf->datalen; amt = inf->datalen;
else if (remainder) else if (remain)
*remainder = inf->datalen - amt; *remain = inf->datalen - amt;
outf.frametype = AST_FRAME_VOICE; outf.frametype = AST_FRAME_VOICE;
outf.subclass = AST_FORMAT_ULAW; outf.subclass = AST_FORMAT_ULAW;
outf.data.ptr = buf; outf.data.ptr = buf;
@ -914,13 +914,13 @@ static int _ast_adsi_channel_restore(struct ast_channel *chan)
} }
static int _ast_adsi_print(struct ast_channel *chan, char **lines, int *aligns, int voice) static int _ast_adsi_print(struct ast_channel *chan, char **lines, int *alignments, int voice)
{ {
unsigned char buf[4096]; unsigned char buf[4096];
int bytes = 0, res, x; int bytes = 0, res, x;
for(x = 0; lines[x]; x++) for(x = 0; lines[x]; x++)
bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, aligns[x], 0, lines[x], ""); bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, alignments[x], 0, lines[x], "");
bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1); bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
if (voice) if (voice)
bytes += ast_adsi_voice_mode(buf + bytes, 0); bytes += ast_adsi_voice_mode(buf + bytes, 0);

@ -518,7 +518,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in
int s, flags, res, port = AGI_PORT; int s, flags, res, port = AGI_PORT;
struct pollfd pfds[1]; struct pollfd pfds[1];
char *host, *c, *script = ""; char *host, *c, *script = "";
struct sockaddr_in sin; struct sockaddr_in addr_in;
struct hostent *hp; struct hostent *hp;
struct ast_hostent ahp; struct ast_hostent ahp;
@ -557,11 +557,11 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in
close(s); close(s);
return -1; return -1;
} }
memset(&sin, 0, sizeof(sin)); memset(&addr_in, 0, sizeof(addr_in));
sin.sin_family = AF_INET; addr_in.sin_family = AF_INET;
sin.sin_port = htons(port); addr_in.sin_port = htons(port);
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr)); memcpy(&addr_in.sin_addr, hp->h_addr, sizeof(addr_in.sin_addr));
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) && (errno != EINPROGRESS)) { if (connect(s, (struct sockaddr *)&addr_in, sizeof(addr_in)) && (errno != EINPROGRESS)) {
ast_log(LOG_WARNING, "Connect failed with unexpected error: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Connect failed with unexpected error: %s\n", strerror(errno));
close(s); close(s);
return AGI_RESULT_FAILURE; return AGI_RESULT_FAILURE;
@ -884,7 +884,7 @@ static int handle_sendimage(struct ast_channel *chan, AGI *agi, int argc, char *
static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{ {
int res = 0, skipms = 3000; int res = 0, skipms = 3000;
char *fwd = "#", *rev = "*", *pause = NULL, *stop = NULL; /* Default values */ char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL; /* Default values */
if (argc < 5 || argc > 9) { if (argc < 5 || argc > 9) {
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
@ -907,10 +907,10 @@ static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc
} }
if (argc > 8 && !ast_strlen_zero(argv[8])) { if (argc > 8 && !ast_strlen_zero(argv[8])) {
pause = argv[8]; suspend = argv[8];
} }
res = ast_control_streamfile(chan, argv[3], fwd, rev, stop, pause, NULL, skipms, NULL); res = ast_control_streamfile(chan, argv[3], fwd, rev, stop, suspend, NULL, skipms, NULL);
ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res); ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
@ -1449,14 +1449,14 @@ static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, char **ar
static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv) static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv)
{ {
int res; int res;
struct ast_app *app; struct ast_app *app_to_exec;
if (argc < 2) if (argc < 2)
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argv[2]); ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argv[2]);
if ((app = pbx_findapp(argv[1]))) { if ((app_to_exec = pbx_findapp(argv[1]))) {
if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) { if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) {
char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr; char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
for (cptr = compat, vptr = argv[2]; *vptr; vptr++) { for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
@ -1470,9 +1470,9 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv
} }
} }
*cptr = '\0'; *cptr = '\0';
res = pbx_exec(chan, app, compat); res = pbx_exec(chan, app_to_exec, compat);
} else { } else {
res = pbx_exec(chan, app, argv[2]); res = pbx_exec(chan, app_to_exec, argv[2]);
} }
} else { } else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]); ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);

@ -66,7 +66,7 @@ static LDAP *ldapConn;
static char url[512]; static char url[512];
static char user[512]; static char user[512];
static char pass[50]; static char pass[50];
static char basedn[512]; static char base_distinguished_name[512];
static int version = 3; static int version = 3;
static time_t connect_time; static time_t connect_time;
@ -345,7 +345,7 @@ static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config
* \return \a vars - an array of ast_variable variables terminated with a null. * \return \a vars - an array of ast_variable variables terminated with a null.
**/ **/
static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_config *table_config, static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_config *table_config,
LDAPMessage *ldap_result, unsigned int *entries_count_ptr) LDAPMessage *ldap_result_msg, unsigned int *entries_count_ptr)
{ {
struct ast_variable **vars; struct ast_variable **vars;
int i = 0; int i = 0;
@ -361,7 +361,7 @@ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_conf
int delim_count = 0; int delim_count = 0;
/* First find the total count */ /* First find the total count */
ldap_entry = ldap_first_entry(ldapConn, ldap_result); ldap_entry = ldap_first_entry(ldapConn, ldap_result_msg);
for (tot_count = 0; ldap_entry; tot_count++){ for (tot_count = 0; ldap_entry; tot_count++){
tot_count += semicolon_count_var(realtime_ldap_entry_to_var(table_config, ldap_entry)); tot_count += semicolon_count_var(realtime_ldap_entry_to_var(table_config, ldap_entry));
@ -377,7 +377,7 @@ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_conf
* This memory must be freed outside of this function. */ * This memory must be freed outside of this function. */
vars = ast_calloc(sizeof(struct ast_variable *), tot_count + 1); vars = ast_calloc(sizeof(struct ast_variable *), tot_count + 1);
ldap_entry = ldap_first_entry(ldapConn, ldap_result); ldap_entry = ldap_first_entry(ldapConn, ldap_result_msg);
i = 0; i = 0;
@ -547,14 +547,14 @@ static struct ast_variable *ldap_loadentry(struct ldap_table_config *table_confi
struct ast_variable **vars = NULL; struct ast_variable **vars = NULL;
struct ast_variable *var = NULL; struct ast_variable *var = NULL;
int result = -1; int result = -1;
LDAPMessage *ldap_result = NULL; LDAPMessage *ldap_result_msg = NULL;
int tries = 0; int tries = 0;
ast_debug(2, "ldap_loadentry dn=%s\n", dn); ast_debug(2, "ldap_loadentry dn=%s\n", dn);
do { do {
result = ldap_search_ext_s(ldapConn, dn, LDAP_SCOPE_BASE, result = ldap_search_ext_s(ldapConn, dn, LDAP_SCOPE_BASE,
"(objectclass=*)", NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &ldap_result); "(objectclass=*)", NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &ldap_result_msg);
if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) { if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
ast_log(LOG_WARNING, ast_log(LOG_WARNING,
"Failed to query database. Try %d/3\n", "Failed to query database. Try %d/3\n",
@ -583,17 +583,17 @@ static struct ast_variable *ldap_loadentry(struct ldap_table_config *table_confi
} else { } else {
int num_entry = 0; int num_entry = 0;
unsigned int *entries_count_ptr = NULL; /*!< not using this */ unsigned int *entries_count_ptr = NULL; /*!< not using this */
if ((num_entry = ldap_count_entries(ldapConn, ldap_result)) > 0) { if ((num_entry = ldap_count_entries(ldapConn, ldap_result_msg)) > 0) {
ast_debug(3, "num_entry: %d\n", num_entry); ast_debug(3, "num_entry: %d\n", num_entry);
vars = realtime_ldap_result_to_vars(table_config, ldap_result, entries_count_ptr); vars = realtime_ldap_result_to_vars(table_config, ldap_result_msg, entries_count_ptr);
if (num_entry > 1) if (num_entry > 1)
ast_log(LOG_NOTICE, "More than one entry for dn=%s. Take only 1st one\n", dn); ast_log(LOG_NOTICE, "More than one entry for dn=%s. Take only 1st one\n", dn);
} else { } else {
ast_debug(2, "Could not find any entry dn=%s.\n", dn); ast_debug(2, "Could not find any entry dn=%s.\n", dn);
} }
} }
ldap_msgfree(ldap_result); ldap_msgfree(ldap_result_msg);
/* Chopping \a vars down to one variable */ /* Chopping \a vars down to one variable */
if (vars != NULL) { if (vars != NULL) {
@ -722,7 +722,7 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p
struct ast_str *filter = NULL; struct ast_str *filter = NULL;
int tries = 0; int tries = 0;
int result = 0; int result = 0;
LDAPMessage *ldap_result = NULL; LDAPMessage *ldap_result_msg = NULL;
if (!table_name) { if (!table_name) {
ast_log(LOG_WARNING, "No table_name specified.\n"); ast_log(LOG_WARNING, "No table_name specified.\n");
@ -789,7 +789,7 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p
/* freeing ldap_result further down */ /* freeing ldap_result further down */
result = ldap_search_ext_s(ldapConn, clean_basedn, result = ldap_search_ext_s(ldapConn, clean_basedn,
LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
&ldap_result); &ldap_result_msg);
if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) { if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
ast_log(LOG_DEBUG, "Failed to query database. Try %d/10\n", ast_log(LOG_DEBUG, "Failed to query database. Try %d/10\n",
tries + 1); tries + 1);
@ -812,15 +812,15 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p
} else { } else {
/* this is where we create the variables from the search result /* this is where we create the variables from the search result
* freeing this \a vars outside this function */ * freeing this \a vars outside this function */
if (ldap_count_entries(ldapConn, ldap_result) > 0) { if (ldap_count_entries(ldapConn, ldap_result_msg) > 0) {
/* is this a static var or some other? they are handled different for delimited values */ /* is this a static var or some other? they are handled different for delimited values */
vars = realtime_ldap_result_to_vars(table_config, ldap_result, entries_count_ptr); vars = realtime_ldap_result_to_vars(table_config, ldap_result_msg, entries_count_ptr);
} else { } else {
ast_debug(1, "Could not find any entry matching %s in base dn %s.\n", ast_debug(1, "Could not find any entry matching %s in base dn %s.\n",
filter->str, clean_basedn); filter->str, clean_basedn);
} }
ldap_msgfree(ldap_result); ldap_msgfree(ldap_result_msg);
/* TODO: get the default variables from the accountBaseDN, not implemented with delimited values */ /* TODO: get the default variables from the accountBaseDN, not implemented with delimited values */
if (vars) { if (vars) {
@ -1090,8 +1090,8 @@ static struct ast_config *config_ldap(const char *basedn, const char *table_name
for (i = 0; i < vars_count; i++) { for (i = 0; i < vars_count; i++) {
if (!strcmp(categories[i].variable_name, "#include")) { if (!strcmp(categories[i].variable_name, "#include")) {
struct ast_flags config_flags = { 0 }; struct ast_flags flags = { 0 };
if (!ast_config_internal_load(categories[i].variable_value, cfg, config_flags, "", who_asked)) if (!ast_config_internal_load(categories[i].variable_value, cfg, flags, "", who_asked))
break; break;
continue; continue;
} }
@ -1139,7 +1139,7 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
struct ast_str *filter = NULL; struct ast_str *filter = NULL;
int tries = 0; int tries = 0;
int result = 0; int result = 0;
LDAPMessage *ldap_result = NULL; LDAPMessage *ldap_result_msg = NULL;
if (!table_name) { if (!table_name) {
ast_log(LOG_WARNING, "No table_name specified.\n"); ast_log(LOG_WARNING, "No table_name specified.\n");
@ -1246,7 +1246,7 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
/* freeing ldap_result further down */ /* freeing ldap_result further down */
result = ldap_search_ext_s(ldapConn, clean_basedn, result = ldap_search_ext_s(ldapConn, clean_basedn,
LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
&ldap_result); &ldap_result_msg);
if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) { if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n", ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n",
tries + 1); tries + 1);
@ -1274,17 +1274,17 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
free(filter); free(filter);
if (clean_basedn) if (clean_basedn)
free(clean_basedn); free(clean_basedn);
ldap_msgfree(ldap_result); ldap_msgfree(ldap_result_msg);
ldap_mods_free(ldap_mods, 0); ldap_mods_free(ldap_mods, 0);
return -1; return -1;
} }
/* Ready to update */ /* Ready to update */
if ((num_entries = ldap_count_entries(ldapConn, ldap_result)) > 0) { if ((num_entries = ldap_count_entries(ldapConn, ldap_result_msg)) > 0) {
ast_debug(3, "LINE(%d) Modifying %s=%s hits: %d\n", __LINE__, attribute, lookup, num_entries); ast_debug(3, "LINE(%d) Modifying %s=%s hits: %d\n", __LINE__, attribute, lookup, num_entries);
for (i = 0; option_debug > 2 && i < mods_size - 1; i++) for (i = 0; option_debug > 2 && i < mods_size - 1; i++)
ast_debug(3, "LINE(%d) %s=%s \n", __LINE__, ldap_mods[i]->mod_type, ldap_mods[i]->mod_values[0]); ast_debug(3, "LINE(%d) %s=%s \n", __LINE__, ldap_mods[i]->mod_type, ldap_mods[i]->mod_values[0]);
ldap_entry = ldap_first_entry(ldapConn, ldap_result); ldap_entry = ldap_first_entry(ldapConn, ldap_result_msg);
for (i = 0; ldap_entry; i++) { for (i = 0; ldap_entry; i++) {
dn = ldap_get_dn(ldapConn, ldap_entry); dn = ldap_get_dn(ldapConn, ldap_entry);
@ -1300,7 +1300,7 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
free(filter); free(filter);
if (clean_basedn) if (clean_basedn)
free(clean_basedn); free(clean_basedn);
ldap_msgfree(ldap_result); ldap_msgfree(ldap_result_msg);
ldap_mods_free(ldap_mods, 0); ldap_mods_free(ldap_mods, 0);
return num_entries; return num_entries;
} }
@ -1430,9 +1430,9 @@ int parse_config(void)
if (!(s = ast_variable_retrieve(config, "_general", "basedn"))) { if (!(s = ast_variable_retrieve(config, "_general", "basedn"))) {
ast_log(LOG_ERROR, "No LDAP base dn found, using '%s' as default.\n", RES_CONFIG_LDAP_DEFAULT_BASEDN); ast_log(LOG_ERROR, "No LDAP base dn found, using '%s' as default.\n", RES_CONFIG_LDAP_DEFAULT_BASEDN);
ast_copy_string(basedn, RES_CONFIG_LDAP_DEFAULT_BASEDN, sizeof(basedn)); ast_copy_string(base_distinguished_name, RES_CONFIG_LDAP_DEFAULT_BASEDN, sizeof(base_distinguished_name));
} else } else
ast_copy_string(basedn, s, sizeof(basedn)); ast_copy_string(base_distinguished_name, s, sizeof(base_distinguished_name));
if (!(s = ast_variable_retrieve(config, "_general", "version")) && !(s = ast_variable_retrieve(config, "_general", "protocol"))) { if (!(s = ast_variable_retrieve(config, "_general", "version")) && !(s = ast_variable_retrieve(config, "_general", "protocol"))) {
ast_log(LOG_NOTICE, "No explicit LDAP version found, using 3 as default.\n"); ast_log(LOG_NOTICE, "No explicit LDAP version found, using 3 as default.\n");
@ -1526,7 +1526,7 @@ static int ldap_reconnect(void)
static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
char status[256], credentials[100] = ""; char status[256], credentials[100] = "";
int ctime = time(NULL) - connect_time; int ctimesec = time(NULL) - connect_time;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
@ -1543,29 +1543,29 @@ static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_c
return CLI_FAILURE; return CLI_FAILURE;
if (!ast_strlen_zero(url)) if (!ast_strlen_zero(url))
snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, basedn); snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, base_distinguished_name);
if (!ast_strlen_zero(user)) if (!ast_strlen_zero(user))
snprintf(credentials, sizeof(credentials), " with username %s", user); snprintf(credentials, sizeof(credentials), " with username %s", user);
if (ctime > 31536000) { if (ctimesec > 31536000) {
ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
status, credentials, ctime / 31536000, status, credentials, ctimesec / 31536000,
(ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctimesec % 31536000) / 86400, (ctimesec % 86400) / 3600,
(ctime % 3600) / 60, ctime % 60); (ctimesec % 3600) / 60, ctimesec % 60);
} else if (ctime > 86400) { } else if (ctimesec > 86400) {
ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n",
status, credentials, ctime / 86400, (ctime % 86400) / 3600, status, credentials, ctimesec / 86400, (ctimesec % 86400) / 3600,
(ctime % 3600) / 60, ctime % 60); (ctimesec % 3600) / 60, ctimesec % 60);
} else if (ctime > 3600) { } else if (ctimesec > 3600) {
ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n",
status, credentials, ctime / 3600, (ctime % 3600) / 60, status, credentials, ctimesec / 3600, (ctimesec % 3600) / 60,
ctime % 60); ctimesec % 60);
} else if (ctime > 60) { } else if (ctimesec > 60) {
ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials,
ctime / 60, ctime % 60); ctimesec / 60, ctimesec % 60);
} else { } else {
ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime); ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctimesec);
} }
return CLI_SUCCESS; return CLI_SUCCESS;

@ -988,7 +988,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
} else { } else {
struct ast_str *sql = ast_str_create(100); struct ast_str *sql = ast_str_create(100);
char fieldtype[15]; char fieldtype[15];
PGresult *res; PGresult *result;
if (requirements == RQ_CREATECHAR || type == RQ_CHAR) { if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
/* Size is minimum length; make it at least 50% greater, /* Size is minimum length; make it at least 50% greater,
@ -1029,12 +1029,12 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
} }
ast_debug(1, "About to run ALTER query on table '%s' to add column '%s'\n", tablename, elm); ast_debug(1, "About to run ALTER query on table '%s' to add column '%s'\n", tablename, elm);
res = PQexec(pgsqlConn, sql->str); result = PQexec(pgsqlConn, sql->str);
ast_debug(1, "Finished running ALTER query on table '%s'\n", tablename); ast_debug(1, "Finished running ALTER query on table '%s'\n", tablename);
if (PQresultStatus(res) != PGRES_COMMAND_OK) { if (PQresultStatus(result) != PGRES_COMMAND_OK) {
ast_log(LOG_ERROR, "Unable to add column: %s\n", sql->str); ast_log(LOG_ERROR, "Unable to add column: %s\n", sql->str);
} }
PQclear(res); PQclear(result);
ast_mutex_unlock(&pgsql_lock); ast_mutex_unlock(&pgsql_lock);
ast_free(sql); ast_free(sql);
@ -1125,11 +1125,11 @@ static int reload(void)
return 0; return 0;
} }
static int parse_config(int reload) static int parse_config(int is_reload)
{ {
struct ast_config *config; struct ast_config *config;
const char *s; const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_flags config_flags = { is_reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) if ((config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0; return 0;
@ -1336,7 +1336,7 @@ static char *handle_cli_realtime_pgsql_cache(struct ast_cli_entry *e, int cmd, s
static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
char status[256], credentials[100] = ""; char status[256], credentials[100] = "";
int ctime = time(NULL) - connect_time; int ctimesec = time(NULL) - connect_time;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
@ -1363,22 +1363,22 @@ static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd,
if (!ast_strlen_zero(dbuser)) if (!ast_strlen_zero(dbuser))
snprintf(credentials, sizeof(credentials), " with username %s", dbuser); snprintf(credentials, sizeof(credentials), " with username %s", dbuser);
if (ctime > 31536000) if (ctimesec > 31536000)
ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
status, credentials, ctime / 31536000, (ctime % 31536000) / 86400, status, credentials, ctimesec / 31536000, (ctimesec % 31536000) / 86400,
(ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60); (ctimesec % 86400) / 3600, (ctimesec % 3600) / 60, ctimesec % 60);
else if (ctime > 86400) else if (ctimesec > 86400)
ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status,
credentials, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, credentials, ctimesec / 86400, (ctimesec % 86400) / 3600, (ctimesec % 3600) / 60,
ctime % 60); ctimesec % 60);
else if (ctime > 3600) else if (ctimesec > 3600)
ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, credentials, ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, credentials,
ctime / 3600, (ctime % 3600) / 60, ctime % 60); ctimesec / 3600, (ctimesec % 3600) / 60, ctimesec % 60);
else if (ctime > 60) else if (ctimesec > 60)
ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ctime / 60, ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ctimesec / 60,
ctime % 60); ctimesec % 60);
else else
ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime); ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctimesec);
return CLI_SUCCESS; return CLI_SUCCESS;
} else { } else {

@ -544,10 +544,10 @@ static void *monmp3thread(void *data)
short sbuf[8192]; short sbuf[8192];
int res, res2; int res, res2;
int len; int len;
struct timeval tv, tv_tmp; struct timeval deadline, tv_tmp;
tv.tv_sec = 0; deadline.tv_sec = 0;
tv.tv_usec = 0; deadline.tv_usec = 0;
for(;/* ever */;) { for(;/* ever */;) {
pthread_testcancel(); pthread_testcancel();
/* Spawn mp3 player if it's not there */ /* Spawn mp3 player if it's not there */
@ -570,16 +570,16 @@ static void *monmp3thread(void *data)
long delta; long delta;
/* Reliable sleep */ /* Reliable sleep */
tv_tmp = ast_tvnow(); tv_tmp = ast_tvnow();
if (ast_tvzero(tv)) if (ast_tvzero(deadline))
tv = tv_tmp; deadline = tv_tmp;
delta = ast_tvdiff_ms(tv_tmp, tv); delta = ast_tvdiff_ms(tv_tmp, deadline);
if (delta < MOH_MS_INTERVAL) { /* too early */ if (delta < MOH_MS_INTERVAL) { /* too early */
tv = ast_tvadd(tv, ast_samp2tv(MOH_MS_INTERVAL, 1000)); /* next deadline */ deadline = ast_tvadd(deadline, ast_samp2tv(MOH_MS_INTERVAL, 1000)); /* next deadline */
usleep(1000 * (MOH_MS_INTERVAL - delta)); usleep(1000 * (MOH_MS_INTERVAL - delta));
pthread_testcancel(); pthread_testcancel();
} else { } else {
ast_log(LOG_NOTICE, "Request to schedule in the past?!?!\n"); ast_log(LOG_NOTICE, "Request to schedule in the past?!?!\n");
tv = tv_tmp; deadline = tv_tmp;
} }
res = 8 * MOH_MS_INTERVAL; /* 8 samples per millisecond */ res = 8 * MOH_MS_INTERVAL; /* 8 samples per millisecond */
} }
@ -985,7 +985,7 @@ static int moh_diff(struct mohclass *old, struct mohclass *new)
return 0; return 0;
} }
static int moh_register(struct mohclass *moh, int reload) static int moh_register(struct mohclass *moh, int is_reload)
{ {
#ifdef HAVE_DAHDI #ifdef HAVE_DAHDI
int x; int x;
@ -1326,21 +1326,21 @@ static void local_ast_moh_stop(struct ast_channel *chan)
chan->name, chan->uniqueid); chan->name, chan->uniqueid);
} }
static int load_moh_classes(int reload) static int load_moh_classes(int is_reload)
{ {
struct ast_config *cfg; struct ast_config *cfg;
struct ast_variable *var; struct ast_variable *var;
struct mohclass *class; struct mohclass *class;
char *cat; char *cat;
int numclasses = 0; int numclasses = 0;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_flags config_flags = { is_reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
cfg = ast_config_load("musiconhold.conf", config_flags); cfg = ast_config_load("musiconhold.conf", config_flags);
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED) if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED)
return 0; return 0;
if (reload) { if (is_reload) {
AST_RWLIST_WRLOCK(&mohclasses); AST_RWLIST_WRLOCK(&mohclasses);
AST_RWLIST_TRAVERSE(&mohclasses, class, list) { AST_RWLIST_TRAVERSE(&mohclasses, class, list) {
class->delete = 1; class->delete = 1;
@ -1417,7 +1417,7 @@ static int load_moh_classes(int reload)
} }
/* Don't leak a class when it's already registered */ /* Don't leak a class when it's already registered */
moh_register(class, reload); moh_register(class, is_reload);
numclasses++; numclasses++;
} }
@ -1431,12 +1431,12 @@ static int load_moh_classes(int reload)
static int ast_moh_destroy_one(struct mohclass *moh) static int ast_moh_destroy_one(struct mohclass *moh)
{ {
char buff[8192]; char buff[8192];
int bytes, tbytes = 0, stime = 0, pid = 0; int bytes, tbytes = 0, stop_time = 0, pid = 0;
if (moh) { if (moh) {
if (moh->pid > 1) { if (moh->pid > 1) {
ast_debug(1, "killing %d!\n", moh->pid); ast_debug(1, "killing %d!\n", moh->pid);
stime = time(NULL) + 2; stop_time = time(NULL) + 2;
pid = moh->pid; pid = moh->pid;
moh->pid = 0; moh->pid = 0;
/* Back when this was just mpg123, SIGKILL was fine. Now we need /* Back when this was just mpg123, SIGKILL was fine. Now we need
@ -1447,7 +1447,7 @@ static int ast_moh_destroy_one(struct mohclass *moh)
kill(pid, SIGTERM); kill(pid, SIGTERM);
usleep(100000); usleep(100000);
kill(pid, SIGKILL); kill(pid, SIGKILL);
while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stop_time)
tbytes = tbytes + bytes; tbytes = tbytes + bytes;
ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
close(moh->srcfd); close(moh->srcfd);
@ -1569,16 +1569,16 @@ static struct ast_cli_entry cli_moh[] = {
AST_CLI_DEFINE(handle_cli_moh_show_files, "List MusicOnHold file-based classes") AST_CLI_DEFINE(handle_cli_moh_show_files, "List MusicOnHold file-based classes")
}; };
static int init_classes(int reload) static int init_classes(int is_reload)
{ {
struct mohclass *moh; struct mohclass *moh;
if (!load_moh_classes(reload)) /* Load classes from config */ if (!load_moh_classes(is_reload)) /* Load classes from config */
return 0; /* Return if nothing is found */ return 0; /* Return if nothing is found */
AST_RWLIST_WRLOCK(&mohclasses); AST_RWLIST_WRLOCK(&mohclasses);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mohclasses, moh, list) { AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mohclasses, moh, list) {
if (reload && moh->delete) { if (is_reload && moh->delete) {
AST_RWLIST_REMOVE_CURRENT(list); AST_RWLIST_REMOVE_CURRENT(list);
if (!moh->inuse) if (!moh->inuse)
ast_moh_destroy_one(moh); ast_moh_destroy_one(moh);

@ -411,7 +411,7 @@ static int load_odbc_config(void)
const char *dsn, *username, *password, *sanitysql; const char *dsn, *username, *password, *sanitysql;
int enabled, pooling, limit, bse; int enabled, pooling, limit, bse;
unsigned int idlecheck; unsigned int idlecheck;
int connect = 0, res = 0; int preconnect = 0, res = 0;
struct ast_flags config_flags = { 0 }; struct ast_flags config_flags = { 0 };
struct odbc_class *new; struct odbc_class *new;
@ -431,7 +431,7 @@ static int load_odbc_config(void)
/* Reset all to defaults for each class of odbc connections */ /* Reset all to defaults for each class of odbc connections */
dsn = username = password = sanitysql = NULL; dsn = username = password = sanitysql = NULL;
enabled = 1; enabled = 1;
connect = idlecheck = 0; preconnect = idlecheck = 0;
pooling = 0; pooling = 0;
limit = 0; limit = 0;
bse = 1; bse = 1;
@ -458,7 +458,7 @@ static int load_odbc_config(void)
} else if (!strcasecmp(v->name, "enabled")) { } else if (!strcasecmp(v->name, "enabled")) {
enabled = ast_true(v->value); enabled = ast_true(v->value);
} else if (!strcasecmp(v->name, "pre-connect")) { } else if (!strcasecmp(v->name, "pre-connect")) {
connect = ast_true(v->value); preconnect = ast_true(v->value);
} else if (!strcasecmp(v->name, "dsn")) { } else if (!strcasecmp(v->name, "dsn")) {
dsn = v->value; dsn = v->value;
} else if (!strcasecmp(v->name, "username")) { } else if (!strcasecmp(v->name, "username")) {
@ -521,7 +521,7 @@ static int load_odbc_config(void)
break; break;
} }
odbc_register_class(new, connect); odbc_register_class(new, preconnect);
ast_log(LOG_NOTICE, "Registered ODBC class '%s' dsn->[%s]\n", cat, dsn); ast_log(LOG_NOTICE, "Registered ODBC class '%s' dsn->[%s]\n", cat, dsn);
ao2_ref(new, -1); ao2_ref(new, -1);
new = NULL; new = NULL;
@ -615,14 +615,14 @@ static struct ast_cli_entry cli_odbc[] = {
AST_CLI_DEFINE(handle_cli_odbc_show, "List ODBC DSN(s)") AST_CLI_DEFINE(handle_cli_odbc_show, "List ODBC DSN(s)")
}; };
static int odbc_register_class(struct odbc_class *class, int connect) static int odbc_register_class(struct odbc_class *class, int preconnect)
{ {
struct odbc_obj *obj; struct odbc_obj *obj;
if (class) { if (class) {
ao2_link(class_container, class); ao2_link(class_container, class);
/* I still have a reference in the caller, so a deref is NOT missing here. */ /* I still have a reference in the caller, so a deref is NOT missing here. */
if (connect) { if (preconnect) {
/* Request and release builds a connection */ /* Request and release builds a connection */
obj = ast_odbc_request_obj(class->name, 0); obj = ast_odbc_request_obj(class->name, 0);
if (obj) if (obj)
@ -774,7 +774,7 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
int res; int res;
SQLINTEGER err; SQLINTEGER err;
short int mlen; short int mlen;
unsigned char msg[200], stat[10]; unsigned char msg[200], state[10];
#ifdef NEEDTRACE #ifdef NEEDTRACE
SQLINTEGER enable = 1; SQLINTEGER enable = 1;
char *tracefile = "/tmp/odbc.trace"; char *tracefile = "/tmp/odbc.trace";
@ -808,7 +808,7 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
(SQLCHAR *) obj->parent->password, SQL_NTS); (SQLCHAR *) obj->parent->password, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
SQLGetDiagRec(SQL_HANDLE_DBC, obj->con, 1, stat, &err, msg, 100, &mlen); SQLGetDiagRec(SQL_HANDLE_DBC, obj->con, 1, state, &err, msg, 100, &mlen);
ast_mutex_unlock(&obj->lock); ast_mutex_unlock(&obj->lock);
ast_log(LOG_WARNING, "res_odbc: Error SQLConnect=%d errno=%d %s\n", res, (int)err, msg); ast_log(LOG_WARNING, "res_odbc: Error SQLConnect=%d errno=%d %s\n", res, (int)err, msg);
return ODBC_FAIL; return ODBC_FAIL;

@ -349,7 +349,7 @@ static void set_timezone_variables(struct varshead *headp, const char *zone)
int tzoffset; int tzoffset;
char buffer[21]; char buffer[21];
struct ast_var_t *var; struct ast_var_t *var;
struct timeval tv; struct timeval when;
time(&utc_time); time(&utc_time);
ast_get_dst_info(&utc_time, &dstenable, &dststart, &dstend, &tzoffset, zone); ast_get_dst_info(&utc_time, &dstenable, &dststart, &dstend, &tzoffset, zone);
@ -364,8 +364,8 @@ static void set_timezone_variables(struct varshead *headp, const char *zone)
if ((var = ast_var_assign("DST_ENABLE", "1"))) if ((var = ast_var_assign("DST_ENABLE", "1")))
AST_LIST_INSERT_TAIL(headp, var, entries); AST_LIST_INSERT_TAIL(headp, var, entries);
tv.tv_sec = dststart; when.tv_sec = dststart;
ast_localtime(&tv, &tm_info, zone); ast_localtime(&when, &tm_info, zone);
snprintf(buffer, sizeof(buffer), "%d", tm_info.tm_mon+1); snprintf(buffer, sizeof(buffer), "%d", tm_info.tm_mon+1);
if ((var = ast_var_assign("DST_START_MONTH", buffer))) if ((var = ast_var_assign("DST_START_MONTH", buffer)))
@ -379,8 +379,8 @@ static void set_timezone_variables(struct varshead *headp, const char *zone)
if ((var = ast_var_assign("DST_START_HOUR", buffer))) if ((var = ast_var_assign("DST_START_HOUR", buffer)))
AST_LIST_INSERT_TAIL(headp, var, entries); AST_LIST_INSERT_TAIL(headp, var, entries);
tv.tv_sec = dstend; when.tv_sec = dstend;
ast_localtime(&tv, &tm_info, zone); ast_localtime(&when, &tm_info, zone);
snprintf(buffer, sizeof(buffer), "%d", tm_info.tm_mon + 1); snprintf(buffer, sizeof(buffer), "%d", tm_info.tm_mon + 1);
if ((var = ast_var_assign("DST_END_MONTH", buffer))) if ((var = ast_var_assign("DST_END_MONTH", buffer)))
@ -408,7 +408,7 @@ static struct ast_str *phoneprov_callback(struct ast_tcptls_session_instance *se
int len; int len;
int fd; int fd;
char buf[256]; char buf[256];
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
struct ast_tm tm; struct ast_tm tm;
if (!(route = ao2_find(http_routes, &search_route, OBJ_POINTER))) { if (!(route = ao2_find(http_routes, &search_route, OBJ_POINTER))) {
@ -432,7 +432,7 @@ static struct ast_str *phoneprov_callback(struct ast_tcptls_session_instance *se
goto out500; goto out500;
} }
ast_strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&tv, &tm, "GMT")); ast_strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&now, &tm, "GMT"));
fprintf(ser->f, "HTTP/1.1 200 OK\r\n" fprintf(ser->f, "HTTP/1.1 200 OK\r\n"
"Server: Asterisk/%s\r\n" "Server: Asterisk/%s\r\n"
"Date: %s\r\n" "Date: %s\r\n"
@ -595,7 +595,7 @@ static void build_profile(const char *name, struct ast_variable *v)
if (!strcasecmp(v->name, "mime_type")) { if (!strcasecmp(v->name, "mime_type")) {
ast_string_field_set(profile, default_mime_type, v->value); ast_string_field_set(profile, default_mime_type, v->value);
} else if (!strcasecmp(v->name, "setvar")) { } else if (!strcasecmp(v->name, "setvar")) {
struct ast_var_t *var; struct ast_var_t *variable;
char *value_copy = ast_strdupa(v->value); char *value_copy = ast_strdupa(v->value);
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
@ -611,8 +611,8 @@ static void build_profile(const char *name, struct ast_variable *v)
args.varval = ast_strip(args.varval); args.varval = ast_strip(args.varval);
if (ast_strlen_zero(args.varname) || ast_strlen_zero(args.varval)) if (ast_strlen_zero(args.varname) || ast_strlen_zero(args.varval))
break; break;
if ((var = ast_var_assign(args.varname, args.varval))) if ((variable = ast_var_assign(args.varname, args.varval)))
AST_LIST_INSERT_TAIL(profile->headp, var, entries); AST_LIST_INSERT_TAIL(profile->headp, variable, entries);
} while (0); } while (0);
} else if (!strcasecmp(v->name, "staticdir")) { } else if (!strcasecmp(v->name, "staticdir")) {
ast_string_field_set(profile, staticdir, v->value); ast_string_field_set(profile, staticdir, v->value);

@ -437,7 +437,7 @@ static void *smdi_message_wait(struct ast_smdi_interface *iface, int timeout,
while (diff < timeout) { while (diff < timeout) {
struct timespec ts = { 0, }; struct timespec ts = { 0, };
struct timeval tv; struct timeval wait;
lock_msg_q(iface, type); lock_msg_q(iface, type);
@ -446,9 +446,9 @@ static void *smdi_message_wait(struct ast_smdi_interface *iface, int timeout,
return msg; return msg;
} }
tv = ast_tvadd(start, ast_tv(0, timeout)); wait = ast_tvadd(start, ast_tv(0, timeout));
ts.tv_sec = tv.tv_sec; ts.tv_sec = wait.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000; ts.tv_nsec = wait.tv_usec * 1000;
/* If there were no messages in the queue, then go to sleep until one /* If there were no messages in the queue, then go to sleep until one
* arrives. */ * arrives. */
@ -778,7 +778,7 @@ static void *mwi_monitor_handler(void *data)
{ {
while (!mwi_monitor.stop) { while (!mwi_monitor.stop) {
struct timespec ts = { 0, }; struct timespec ts = { 0, };
struct timeval tv; struct timeval polltime;
struct mailbox_mapping *mm; struct mailbox_mapping *mm;
ast_mutex_lock(&mwi_monitor.lock); ast_mutex_lock(&mwi_monitor.lock);
@ -790,9 +790,9 @@ static void *mwi_monitor_handler(void *data)
/* Sleep up to the configured polling interval. Allow unload_module() /* Sleep up to the configured polling interval. Allow unload_module()
* to signal us to wake up and exit. */ * to signal us to wake up and exit. */
tv = ast_tvadd(mwi_monitor.last_poll, ast_tv(mwi_monitor.polling_interval, 0)); polltime = ast_tvadd(mwi_monitor.last_poll, ast_tv(mwi_monitor.polling_interval, 0));
ts.tv_sec = tv.tv_sec; ts.tv_sec = polltime.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000; ts.tv_nsec = polltime.tv_usec * 1000;
ast_cond_timedwait(&mwi_monitor.cond, &mwi_monitor.lock, &ts); ast_cond_timedwait(&mwi_monitor.cond, &mwi_monitor.lock, &ts);
ast_mutex_unlock(&mwi_monitor.lock); ast_mutex_unlock(&mwi_monitor.lock);

@ -87,7 +87,7 @@ struct pthread_timer {
}; };
static void pthread_timer_destructor(void *obj); static void pthread_timer_destructor(void *obj);
static struct pthread_timer *find_timer(int handle, int unlink); static struct pthread_timer *find_timer(int handle, int unlinkobj);
static void write_byte(int wr_fd); static void write_byte(int wr_fd);
static void read_pipe(int rd_fd, unsigned int num, int clear); static void read_pipe(int rd_fd, unsigned int num, int clear);
@ -256,7 +256,7 @@ static unsigned int pthread_timer_get_max_rate(int handle)
return MAX_RATE; return MAX_RATE;
} }
static struct pthread_timer *find_timer(int handle, int unlink) static struct pthread_timer *find_timer(int handle, int unlinkobj)
{ {
struct pthread_timer *timer; struct pthread_timer *timer;
struct pthread_timer tmp_timer; struct pthread_timer tmp_timer;
@ -264,7 +264,7 @@ static struct pthread_timer *find_timer(int handle, int unlink)
tmp_timer.pipe[PIPE_READ] = handle; tmp_timer.pipe[PIPE_READ] = handle;
if (unlink) { if (unlinkobj) {
flags |= OBJ_UNLINK; flags |= OBJ_UNLINK;
} }
@ -348,7 +348,7 @@ static void read_pipe(int rd_fd, unsigned int quantity, int clear)
unsigned char buf[1024]; unsigned char buf[1024];
ssize_t res; ssize_t res;
fd_set rfds; fd_set rfds;
struct timeval tv = { struct timeval timeout = {
.tv_sec = 0, .tv_sec = 0,
}; };
@ -356,7 +356,7 @@ static void read_pipe(int rd_fd, unsigned int quantity, int clear)
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(rd_fd, &rfds); FD_SET(rd_fd, &rfds);
if (select(rd_fd + 1, &rfds, NULL, NULL, &tv) != 1) { if (select(rd_fd + 1, &rfds, NULL, NULL, &timeout) != 1) {
break; break;
} }

Loading…
Cancel
Save