From 12ad49e444d6108b7312a46b389090d51b670a7f Mon Sep 17 00:00:00 2001 From: bbryant Date: Thu, 9 Sep 2010 18:50:13 +0000 Subject: Fixes an issue with dialplan pattern matching where the specificity for pattern ranges and pattern special characters was inconsistent. (closes issue #16903) Reported by: Nick_Lewis Patches: pbx.c-specificity.patch uploaded by Nick Lewis (license 657) Tested by: Nick_Lewis git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@285710 f38db490-d61c-443f-a65b-d21fe96a405b --- res/res_ais.c | 20 +++++++++++--------- res/res_config_odbc.c | 2 +- res/res_config_pgsql.c | 15 +++++++++++---- res/res_jabber.c | 26 ++++++++------------------ res/res_musiconhold.c | 25 ++++++++++++++++++++++++- 5 files changed, 55 insertions(+), 33 deletions(-) (limited to 'res') diff --git a/res/res_ais.c b/res/res_ais.c index adb3290e1..9bcceeade 100644 --- a/res/res_ais.c +++ b/res/res_ais.c @@ -113,9 +113,9 @@ const char *ais_err2str(SaAisErrorT error) static void *dispatch_thread_handler(void *data) { - SaSelectionObjectT clm_fd, evt_fd, max_fd; + SaSelectionObjectT clm_fd, evt_fd; int res; - fd_set read_fds; + struct pollfd pfd[2] = { { .events = POLLIN, }, { .events = POLLIN, } }; SaAisErrorT ais_res; ais_res = saClmSelectionObjectGet(clm_handle, &clm_fd); @@ -132,24 +132,26 @@ static void *dispatch_thread_handler(void *data) return NULL; } - max_fd = clm_fd > evt_fd ? clm_fd : evt_fd; + pfd[0].fd = clm_fd; + pfd[1].fd = evt_fd; while (!dispatch_thread.stop) { - FD_ZERO(&read_fds); - FD_SET(clm_fd, &read_fds); - FD_SET(evt_fd, &read_fds); + pfd[0].revents = 0; + pfd[1].revents = 0; - res = ast_select(max_fd + 1, &read_fds, NULL, NULL, NULL); + res = ast_poll(pfd, 2, -1); if (res == -1 && errno != EINTR && errno != EAGAIN) { ast_log(LOG_ERROR, "Select error (%s) dispatch thread going away now, " "and the module will no longer operate.\n", strerror(errno)); break; } - if (FD_ISSET(clm_fd, &read_fds)) + if (pfd[0].revents & POLLIN) { saClmDispatch(clm_handle, SA_DISPATCH_ALL); - if (FD_ISSET(evt_fd, &read_fds)) + } + if (pfd[1].revents & POLLIN) { saEvtDispatch(evt_handle, SA_DISPATCH_ALL); + } } return NULL; diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index 90d5c4ea3..ef45bfc99 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -62,7 +62,7 @@ static void decode_chunk(char *chunk) { for (; *chunk; chunk++) { if (*chunk == '^' && strchr("0123456789ABCDEFabcdef", chunk[1]) && strchr("0123456789ABCDEFabcdef", chunk[2])) { - sscanf(chunk + 1, "%02hhd", chunk); + sscanf(chunk + 1, "%02hhX", chunk); memmove(chunk + 1, chunk + 3, strlen(chunk + 3) + 1); } } diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index 14146e330..38d38e345 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -296,7 +296,7 @@ static char *decode_chunk(char *chunk) char *orig = chunk; for (; *chunk; chunk++) { if (*chunk == '^' && strchr("0123456789ABCDEFabcdef", chunk[1]) && strchr("0123456789ABCDEFabcdef", chunk[2])) { - sscanf(chunk + 1, "%02hhd", chunk); + sscanf(chunk + 1, "%02hhX", chunk); memmove(chunk + 1, chunk + 3, strlen(chunk + 3) + 1); } } @@ -1191,9 +1191,16 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap size, column->type); res = -1; } - } else if (strncmp(column->type, "float", 5) == 0 && !ast_rq_is_int(type) && type != RQ_FLOAT) { - ast_log(LOG_WARNING, "Column %s cannot be a %s\n", column->name, column->type); - res = -1; + } else if (strncmp(column->type, "float", 5) == 0) { + if (!ast_rq_is_int(type) && type != RQ_FLOAT) { + ast_log(LOG_WARNING, "Column %s cannot be a %s\n", column->name, column->type); + res = -1; + } + } else if (strncmp(column->type, "timestamp", 9) == 0) { + if (type != RQ_DATETIME && type != RQ_DATE) { + ast_log(LOG_WARNING, "Column %s cannot be a %s\n", column->name, column->type); + res = -1; + } } else { /* There are other types that no module implements yet */ ast_log(LOG_WARNING, "Possibly unsupported column type '%s' on column '%s'\n", column->type, column->name); res = -1; diff --git a/res/res_jabber.c b/res/res_jabber.c index fbcde691f..7912f88ba 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -668,37 +668,27 @@ static int aji_tls_handshake(struct aji_client *client) */ static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, int timeout) { - int sock; - fd_set fds; - struct timeval tv, *tvptr = NULL; + struct pollfd pfd = { .events = POLLIN }; int len, res; #ifdef HAVE_OPENSSL if (aji_is_secure(client)) { - sock = SSL_get_fd(client->ssl_session); - if (sock < 0) - return -1; + pfd.fd = SSL_get_fd(client->ssl_session); + if (pfd.fd < 0) { + return -1; + } } else #endif /* HAVE_OPENSSL */ - sock = iks_fd(client->p); - - memset(&tv, 0, sizeof(struct timeval)); - FD_ZERO(&fds); - FD_SET(sock, &fds); - tv.tv_sec = timeout; - - /* NULL value for tvptr makes ast_select wait indefinitely */ - tvptr = (timeout != -1) ? &tv : NULL; + pfd.fd = iks_fd(client->p); - /* ast_select emulates linux behaviour in terms of timeout handling */ - res = ast_select(sock + 1, &fds, NULL, NULL, tvptr); + res = ast_poll(&pfd, 1, timeout > 0 ? timeout * 1000 : -1); if (res > 0) { #ifdef HAVE_OPENSSL if (aji_is_secure(client)) { len = SSL_read(client->ssl_session, buffer, buf_len); } else #endif /* HAVE_OPENSSL */ - len = recv(sock, buffer, buf_len, 0); + len = recv(pfd.fd, buffer, buf_len, 0); if (len > 0) { return len; diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 1f86b88e3..fcae10f0e 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -294,10 +294,17 @@ static int ast_moh_files_next(struct ast_channel *chan) state->samples = 0; } - if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) { + for (tries = 0; tries < state->class->total_files; ++tries) { + if (ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) { + break; + } + ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", state->class->filearray[state->pos], strerror(errno)); state->pos++; state->pos %= state->class->total_files; + } + + if (tries == state->class->total_files) { return -1; } @@ -1081,6 +1088,19 @@ static int init_files_class(struct mohclass *class) return 0; } +static void moh_rescan_files(void) { + struct ao2_iterator i; + struct mohclass *c; + + i = ao2_iterator_init(mohclasses, 0); + + while ((c = ao2_iterator_next(&i))) { + moh_scan_files(c); + ao2_ref(c, -1); + } + + ao2_iterator_destroy(&i); +} static int moh_diff(struct mohclass *old, struct mohclass *new) { @@ -1584,6 +1604,9 @@ static int load_moh_classes(int reload) ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes"); ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes"); } + if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + moh_rescan_files(); + } return 0; } -- cgit v1.2.3