Merge changes from topic 'ASTERISK-27625'
authorGeorge Joseph <gjoseph@digium.com>
Thu, 21 Jun 2018 15:26:31 +0000 (10:26 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Thu, 21 Jun 2018 15:26:31 +0000 (10:26 -0500)
* changes:
  channel.c: Make CHECK_BLOCKING() save thread LWP id for messages.
  channel.c: Fix usage of CHECK_BLOCKING()
  autoservice: Don't start channel autoservice if the thread is a user interface.

channels/chan_dahdi.c
channels/sig_analog.c
funcs/func_curl.c
funcs/func_realtime.c
include/asterisk/tcptls.h
include/asterisk/utils.h
main/channel.c
main/enum.c
main/pbx_functions.c
menuselect/menuselect_curses.c

index 34aed16..f4f6514 100644 (file)
@@ -10045,7 +10045,9 @@ static void *analog_ss_thread(void *data)
                                 * emulation.  The DTMF digits can come so fast that emulation
                                 * can drop some of them.
                                 */
+                               ast_channel_lock(chan);
                                ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
+                               ast_channel_unlock(chan);
                                off_ms = 4000;/* This is a typical OFF time between rings. */
                                for (;;) {
                                        struct ast_frame *f;
@@ -10078,7 +10080,9 @@ static void *analog_ss_thread(void *data)
                                                ast_channel_state(chan) == AST_STATE_RINGING)
                                                break; /* Got ring */
                                }
+                               ast_channel_lock(chan);
                                ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
+                               ast_channel_unlock(chan);
                                dtmfbuf[k] = '\0';
                                dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
                                /* Got cid and ring. */
index 53f9fb2..74b4789 100644 (file)
@@ -2414,7 +2414,9 @@ static void *__analog_ss_thread(void *data)
                                 * emulation.  The DTMF digits can come so fast that emulation
                                 * can drop some of them.
                                 */
+                               ast_channel_lock(chan);
                                ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
+                               ast_channel_unlock(chan);
                                timeout_ms = 4000;/* This is a typical OFF time between rings. */
                                for (;;) {
                                        struct ast_frame *f;
@@ -2449,7 +2451,9 @@ static void *__analog_ss_thread(void *data)
                                                break; /* Got ring */
                                        }
                                }
+                               ast_channel_lock(chan);
                                ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
+                               ast_channel_unlock(chan);
                                dtmfbuf[k] = '\0';
 
                                analog_set_linear_mode(p, idx, oldlinearity);
index 682ad5a..9e8f882 100644 (file)
@@ -672,14 +672,19 @@ static int acf_curl_helper(struct ast_channel *chan, struct curl_args *args)
        }
        AST_LIST_UNLOCK(&global_curl_info);
 
-       if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
-               list = store->data;
-               AST_LIST_LOCK(list);
-               AST_LIST_TRAVERSE(list, cur, list) {
-                       if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
-                               hashcompat = (long) cur->value;
-                       } else {
-                               curl_easy_setopt(*curl, cur->key, cur->value);
+       if (chan) {
+               ast_channel_lock(chan);
+               store = ast_channel_datastore_find(chan, &curl_info, NULL);
+               ast_channel_unlock(chan);
+               if (store) {
+                       list = store->data;
+                       AST_LIST_LOCK(list);
+                       AST_LIST_TRAVERSE(list, cur, list) {
+                               if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
+                                       hashcompat = (long) cur->value;
+                               } else {
+                                       curl_easy_setopt(*curl, cur->key, cur->value);
+                               }
                        }
                }
        }
index e0ba4a5..ef7fe2a 100644 (file)
@@ -225,6 +225,9 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha
 
        if (resultslen > len) {
                ast_log(LOG_WARNING, "Failed to fetch. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
+               if (chan) {
+                       ast_autoservice_stop(chan);
+               }
                return -1;
        }
 
@@ -458,6 +461,9 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c
                         * someones data without giving him the chance to look
                         * at it. */
                        ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
+                       if (chan) {
+                               ast_autoservice_stop(chan);
+                       }
                        return -1;
                }
 
index 0a6e25e..0b943ce 100644 (file)
@@ -58,9 +58,6 @@
 #include "asterisk/netsock2.h"  /* for ast_sockaddr */
 #include "asterisk/utils.h"     /* for ast_flags */
 
-struct ssl_ctx_st;              /* forward declaration */
-typedef struct ssl_ctx_st SSL_CTX;
-
 /*! SSL support */
 #define AST_CERTFILE "asterisk.pem"
 
index 6f9a11e..f459b31 100644 (file)
@@ -818,7 +818,7 @@ static inline void _raii_cleanup_block(_raii_cleanup_block_t *b) { (*b)(); }
  */
 char *ast_crypt(const char *key, const char *salt);
 
-/*
+/*!
  * \brief Asterisk wrapper around crypt(3) for encrypting passwords.
  *
  * This function will generate a random salt and encrypt the given password.
@@ -831,7 +831,7 @@ char *ast_crypt(const char *key, const char *salt);
  */
 char *ast_crypt_encrypt(const char *key);
 
-/*
+/*!
  * \brief Asterisk wrapper around crypt(3) for validating passwords.
  *
  * \param key User's password to validate.
@@ -841,7 +841,7 @@ char *ast_crypt_encrypt(const char *key);
  */
 int ast_crypt_validate(const char *key, const char *expected);
 
-/*
+/*!
  * \brief Test that a file exists and is readable by the effective user.
  * \since 13.7.0
  *
@@ -851,7 +851,7 @@ int ast_crypt_validate(const char *key, const char *expected);
  */
 int ast_file_is_readable(const char *filename);
 
-/*
+/*!
  * \brief Compare 2 major.minor.patch.extra version strings.
  * \since 13.7.0
  *
@@ -864,7 +864,7 @@ int ast_file_is_readable(const char *filename);
  */
 int ast_compare_versions(const char *version1, const char *version2);
 
-/*
+/*!
  * \brief Test that an OS supports IPv6 Networking.
  * \since 13.14.0
  *
@@ -878,7 +878,7 @@ enum ast_fd_flag_operation {
        AST_FD_FLAG_CLEAR,
 };
 
-/*
+/*!
  * \brief Set flags on the given file descriptor
  * \since 13.19
  *
@@ -894,7 +894,7 @@ enum ast_fd_flag_operation {
 #define ast_fd_set_flags(fd, flags) \
        __ast_fd_set_flags((fd), (flags), AST_FD_FLAG_SET, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
-/*
+/*!
  * \brief Clear flags on the given file descriptor
  * \since 13.19
  *
index c4b63c6..094658d 100644 (file)
@@ -5921,7 +5921,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
         */
        ast_set_callerid(chan, cid_num, cid_name, cid_num);
 
+       ast_channel_lock(chan);
        ast_set_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED);
+       ast_channel_unlock(chan);
        ast_party_connected_line_set_init(&connected, ast_channel_connected(chan));
        if (cid_num) {
                connected.id.number.valid = 1;
index a44a60c..8b6d3fe 100644 (file)
@@ -941,10 +941,6 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txt
 
        ast_debug(4, "ast_get_txt: Number = '%s', suffix = '%s'\n", number, suffix);
 
-       if (chan && ast_autoservice_start(chan) < 0) {
-               return -1;
-       }
-
        if (pos > 128) {
                pos = 128;
        }
@@ -965,9 +961,6 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txt
        } else {
                ast_copy_string(txt, context.txt, txtlen);
        }
-       if (chan) {
-               ret |= ast_autoservice_stop(chan);
-       }
        return ret;
 }
 
index 3c15e9d..bb3c663 100644 (file)
@@ -300,7 +300,8 @@ int ast_custom_function_unregister(struct ast_custom_function *acf)
  * \return True (non-zero) if reads escalate privileges.
  * \return False (zero) if reads just read.
  */
-static int read_escalates(const struct ast_custom_function *acf) {
+static int read_escalates(const struct ast_custom_function *acf)
+{
        return acf->read_escalates;
 }
 
@@ -311,7 +312,8 @@ static int read_escalates(const struct ast_custom_function *acf) {
  * \return True (non-zero) if writes escalate privileges.
  * \return False (zero) if writes just write.
  */
-static int write_escalates(const struct ast_custom_function *acf) {
+static int write_escalates(const struct ast_custom_function *acf)
+{
        return acf->write_escalates;
 }
 
index 97f1f17..0917eba 100644 (file)
@@ -227,7 +227,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
                                buf[0] = '\0';
                                new_line = 1;
                        }
-                       sprintf(buf, "%s%*.*s%s", buf, new_line ? 0 : 1, new_line ? 0 : 1, " ", word);
+                       sprintf(buf + strlen(buf), "%*.*s%s", new_line ? 0 : 1, new_line ? 0 : 1, " ", word);
                        new_line = 0;
                }
                if (strlen(buf)) {