Commit Graph

5090 Commits

Author SHA1 Message Date
Joshua Colp a1fcf6f7b2 hashtab: Add NULL check when destroying iterator.
The hashtab API is pretty NULL tolerant which has resulted
in remaining callers not doing much checks themselves.
Unfortunately the function to destroy an iterator does not
do a NULL check and will result in a crash if passed NULL.
This change fixes that.

ASTERISK-25552 #close

Change-Id: Ic1bf8eec3639e5a440f1c941d3ae3893ac6ed619
2015-11-14 08:06:48 -05:00
Mark Michelson e8881e1770 Taskprocessors: Increase high-water mark
In practical tests, we have seen certain taskprocessors, specifically
Stasis subscription taskprocessors, cross the recently-added high-water
mark and emit a warning. This high-water mark warning is only intended
to be emitted when things have tanked on the system and things are
heading south quickly. In the practical tests, the Stasis taskprocessors
sometimes had a max depth of 180 tasks in them, and Asterisk wasn't in
any danger at all.

As such, this ups the high-water mark to 500 tasks instead. It also
redefines the SIP threadpool request denial number to be a multiple of
the taskprocessor high-water mark.

Change-Id: Ic8d3e9497452fecd768ac427bb6f58aa616eebce
2015-11-13 14:19:35 -06:00
Joshua Colp 6879ce7fba Merge "res_pjsip: Deny requests when threadpool queue is backed up." 2015-11-12 10:56:09 -06:00
Mark Michelson 264c74aa22 res_pjsip: Deny requests when threadpool queue is backed up.
We have observed situations where the SIP threadpool may become
deadlocked. However, because incoming traffic is still arriving, the SIP
threadpool's queue can continue to grow, eventually running the system
out of memory.

This change makes it so that incoming traffic gets rejected with a 503
response if the queue is backed up too much.

Change-Id: I4e736d48a2ba79fd1f8056c0dcd330e38e6a3816
2015-11-12 11:39:41 -05:00
Joshua Colp a159747660 format_cap: Don't append the 'none' format when appending all.
When appending all formats of a type all the codecs are iterated
and added. This operation was incorrectly adding the ast_format_none
format which is special in that it is supposed to be used when no
format is present. It shouldn't be appended.

ASTERISK-25535

Change-Id: I7b00f3bdf4a5f3022e483d6ece602b1e8b12827c
2015-11-12 08:48:42 -05:00
Joshua Colp 2954354404 threadpool: Handle worker thread transitioning to dead when going active.
This change adds handling of dead worker threads when moving them
to be active. When this happens the worker thread is removed from
both the active and idle threads container. If no threads are able
to be moved to active then the pool grows as configured.

A unit test has also been added which thrashes the idle timeout
and thread activation to exploit any race conditions between the
two.

ASTERISK-25546 #close

Change-Id: I6c455f9a40de60d9e86458d447b548fb52ba1143
2015-11-11 14:18:39 -05:00
Matt Jordan c1abe8906d Merge "rtp_engine: Init a format-attribute module to its RFC defaults." 2015-11-11 08:19:39 -06:00
Matt Jordan 9c9ebbd482 Merge "dns: Use ntohl for ans->ttl in dns_parse_answer_ex" 2015-11-11 08:09:06 -06:00
Matt Jordan 7987bf54c6 Merge "ast_format_cap: Avoid format creation on module load, use cache instead." 2015-11-11 08:08:02 -06:00
Matt Jordan 8b4b3e9b88 Merge "xmldoc: Improve xmldoc wrapping of 'core show ...' output." 2015-11-11 08:06:54 -06:00
Alexander Traud 525c7ab780 rtp_engine: Init a format-attribute module to its RFC defaults.
Previously, format-attribute modules relied on an existing fmtp line in SDP
negotiation. However, fmtp is optional for several formats like the Opus Codec.
Now, the format-attribute module is called with an empty fmtp, which allows the
module to initialise itself to RFC defaults. Furthermore now, Asterisk is able
to differentiate between internally and externally created formats.

ASTERISK-25537 #close

Change-Id: I28f680cef7fdf51c0969ff8da71548edad72ec52
2015-11-11 15:00:26 +01:00
Joshua Colp d8dadf4894 Merge "taskprocessor: Add high water mark warnings" 2015-11-11 07:10:42 -06:00
Joshua Colp e4af14784e Merge "Remove ABI compatibility stub functions." 2015-11-10 16:11:07 -06:00
Joshua Colp 0be147f713 Merge "ast_format_cap_get_names: To display all formats, the buffer was increased." 2015-11-10 14:58:18 -06:00
Corey Farrell be93036a4e Remove ABI compatibility stub functions.
ABI compatibility stubs existed for ast_app_separate_args and ast_verbose,
this is not needed in master.

Change-Id: I07b4d2c16079da3c2c6efa55df4a74368e0bd453
2015-11-10 15:37:09 -05:00
Corey Farrell 02a124eda5 Remove execute permission from dns_system_resolver.c
Change-Id: I3185735db42064bab00d3e073aed703385a00bf4
2015-11-10 15:35:27 -05:00
Alexander Traud cf79b62778 ast_format_cap_get_names: To display all formats, the buffer was increased.
ASTERISK-25533 #close

Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a
2015-11-09 16:58:52 +01:00
Alexander Traud e85f0c81af ast_format_cap: Avoid format creation on module load, use cache instead.
Since Asterisk 13, formats are immutable and cached. However while loading a
module like chan_sip, some formats were created instead using cached ones.

ASTERISK-25535 #close

Change-Id: I479cdc220d5617c840a98f3389b3bd91e91fbd9b
2015-11-09 14:05:14 +01:00
George Joseph d82a4b098f dns: Use ntohl for ans->ttl in dns_parse_answer_ex
dns_parse_answer_ex was not converting ans->ttl from network
by order to host byte order which was causing certain ttls
it to go negative. In turn this was causing answer edit checks
to fail.

ASTERISK-25528 #close
Reported-by: Daniel Tryba
Tested-by: George Joseph

Change-Id: I31505132d6321c46d2f39fd06c20ee808a864037
2015-11-06 13:19:11 -07:00
Walter Doekes 74e7333317 xmldoc: Improve xmldoc wrapping of 'core show ...' output.
Previously, the wrapping did both lookahead and lookback, which,
together with color escape sequences, caused some lines to be wrapped
way earlier than other lines.  This led to inconsistent output.

This simplifies the wrapping code and makes it more sane: if maxcolumns
is hit, we simply jump back to the last space and wrap there.

ASTERISK-25527 #close

Change-Id: I56d01c6f9a812642b1b05535c98d4db48d17c957
2015-11-06 08:46:24 -05:00
Jonathan Rose a2c2a8e1bb taskprocessor: Add high water mark warnings
If a taskprocessor's queue grows large, this can indicate that there
may be a problem with tasks not leaving the processor or else that
the number of available task processors for a given type of task is
too low. This patch makes it so that if a taskprocessor's task queue
grows above 100 queued tasks that it will emit a warning message.
Warning messages are emitted only once per task processor.

ASTERISK-25518 #close
Reported by: Jonathan Rose

Change-Id: Ib1607c35d18c1d6a0575b3f0e3ff5d932fd6600c
2015-11-05 16:20:40 -06:00
Matt Jordan 9c293b5104 main/dial: Protect access to the format_cap structure of the requesting channel
When a dial attempt is made that involves a requesting channel, we previously
were not:
a) Protecting access to the native format capabilities structure on the
   requesting channel. That is inherently unsafe.
b) Reference bumping the lifetime of the format capabilities structure.

In both cases, something else could sneak in, blow away the format
capabilities, and we'd be holding onto an invalid format_cap structure. When
the newly created channel attempts to construct its format capabilities, things
go poorly.

This patch:
a) Ensures that we get a reference to the native format capabilities while
   the requesting channel is locked
b) Holds a reference to the native format capabilities during the creation
   of the new channel.

ASTERISK-25522 #close

Change-Id: I0bfb7ba8b9711f4158cbeaae96edf9626e88a54f
2015-11-04 15:42:32 -05:00
Corey Farrell b0bf189908 Fix cli display of build options.
A previous commit reduced the AST_BUILDOPTS compiler define to
only include options that affected ABI.  This included some options
that were previously displayed by cli "core show settings".  This
change corrects the CLI display while still restricting buildopts.h
to ABI effecting options only.

ASTERISK-25434 #close
Reported by: Rusty Newton

Change-Id: Id07af6bedd1d7d325878023e403fbd9d3607e325
2015-11-04 09:15:51 -05:00
Matt Jordan e26a06c1da main/stasis_endpoints: Fix ContactStatusChange JSON for roundtrip_usec field
The JSON packing for the ContactStatusChange event forgot to include the
roundtrip_usec field. As a result, the field never showed up in any event,
even when the data was available. This patch corrects that error by properly
packing the JSON blob with the data.

Change-Id: I8df80da659a44010afbd48f645967518ff5daa17
2015-11-03 09:18:41 -05:00
Matt Jordan 6b1e9fbdcf Merge "format: Update the maximum packetization time for iLBC 30." 2015-10-26 10:50:10 -05:00
Joshua Colp d73bd56b0a Merge topic 'fix_oom_crash'
* changes:
  strings.c: Fix __ast_str_helper() to always return a terminated string.
  Add missing failure checks to ast_str_set_va() callers.
2015-10-23 06:51:18 -05:00
Mark Michelson 5dd9e1938a format_cap: Detect vector allocation failures.
A crash was seen on a system that ran out of memory due to Asterisk not
checking for vector allocation failures in format_cap.c. With this
change, if either of the AST_VECTOR_INIT calls fail, we will return a
value indicating failure.

Change-Id: Ieb9c59f39dfde6d11797a92b45e0cf8ac5722bc8
2015-10-22 17:29:15 -05:00
Richard Mudgett 1ce62b2545 strings.c: Fix __ast_str_helper() to always return a terminated string.
Users of functions which call __ast_str_helper() such as the ones listed
below are likely to not check the return value for failure so ensuring
that the string is always nil terminated is a good safety measure.

ast_str_set_va()
ast_str_append_va()
ast_str_set()
ast_str_append()

Change-Id: I36ab2d14bb6015868b49329dda8639d70fbcae07
2015-10-21 16:49:13 -05:00
Richard Mudgett a04d946eaa Add missing failure checks to ast_str_set_va() callers.
Change-Id: I0c2cdcd53727bdc6634095c61294807255bd278f
2015-10-21 16:49:13 -05:00
Alexander Traud f9cbac7321 format: Update the maximum packetization time for iLBC 30.
In September 2006, the maximum packetization time (ptime) were set to such a
low value, packetization was disabled for many codecs actually. This was fixed
for many codecs but not for iLBC 30. This enables packetization for iLBC which
can be enabled for example via allow=ilbc:60,gsm,alaw,ulaw in the file sip.conf.

ASTERISK-7803

Change-Id: I2ef90023d35efb7cb8fe96ed74f53f6846ffad12
2015-10-21 12:10:36 -05:00
Jonh Wendell 77780790e0 main/cdr: Allow modules to modify CDR fields before dispatching them
This patch adds the functions

	ast_cdr_modifier_register()
	ast_cdr_modifier_unregister()

That work much like ast_cdr_register() and ast_cdr_unregister().

Modules registered will be given a chance to modify (or to do whatever
they want) CDR fields just before they are passed to registered engines.

Thus, for instance, if a module change the "userfield" field of a CDR,
the modified value will be passed to every registered CDR backend for
logging.

ASTERISK-25479 #close

Change-Id: If11d8fd19ef89b1a66ecacf1201e10fcf86ccd56
2015-10-20 12:12:50 -05:00
Richard Mudgett 984f100dab config.c: Fix off-nominal memory leak.
Change-Id: I06e346e9a5c63cc5071e7eda537310c4b43bffe0
2015-10-12 15:11:39 -05:00
Richard Mudgett 9951255775 config.c: Fix potential memory corruption after [section](+).
The memory corruption could happen if the [section](+) is the last section
in the file with trailing comments.  In this case process_text_line() has
left *last_cat is set to newcat and newcat is destroyed.

Change-Id: I0d1d999f553986f591becd000e7cc6ddfb978d93
2015-10-12 15:11:39 -05:00
Richard Mudgett c1ed11ee31 config.c: Fix #include after [section](+).
An #include right after a [section](+) would associate any variable
assignments before a new section in the #include with the wrong section.

* Fix section association by setting the current section to the appended
section.

* Fix '+' and '!' section flag interaction corner case depending upon
which flag came first.  If the '!' came first then it would be ignored.
If the '!' came after then it would affect the appended section.  The '!'
will now no longer be ignored.

ASTERISK-25461 #close
Reported by: Sean Pimental

Change-Id: Ic9d3191c8758048e2cbce6432f854b32531731c3
2015-10-12 15:11:39 -05:00
Ivan Poddubny 89dec7675d manager: Fix GetConfigJSON returning invalid JSON
When GetConfigJSON was introduced back in 1.6, it returned each
section as an array of strings: ["key=value", "key2=value2"].
Afterwards, it was changed a few times and became
["key": "value", "key2": "value2"], which is not a correct JSON.
This patch fixes that by constructing a JSON object {} instead of
an array [].

Also, the keys "istemplate" and "tempates" that are used to
indicate templates and their inherited categories are now wrapped in
quotes.

ASTERISK-25391 #close
Reported by: Bojan Nemčić

Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
2015-10-03 15:15:52 +03:00
Richard Mudgett 9bc7386b7c sched.c: Add warning about negative time interval request.
Change-Id: Ib91435fb45b7f5f7c0fc83d0eec20b88098707bc
2015-09-30 10:47:12 -05:00
Matt Jordan 2d7a4a3357 main/logger: Add log formatters and JSON structured logs
When Asterisk is part of a larger distributed system, log files are often
gathered using tools (such as logstash) that prefer to consume information
and have it rendered using other tools (such as Kibana) that prefer a
structured format, e.g., JSON. This patch adds support for JSON formatted
logs by adding support for an optional log format specifier in Asterisk's
logging subsystem. By adding a format specifier of '[json]':

full => [json]debug,verbose,notice,warning,error

Log messages will be output to the 'full' channel in the following
format:

{
  "hostname": Hostname or name specified in asterisk.conf
  "timestamp": Date/Time
  "identifiers": {
    "lwp": Thread ID,
    "callid": Call Identifier
  }
  "logmsg": {
    "location": {
      "filename": Name of the file that generated the log statement
      "function": Function that generated the log statement
      "line": Line number that called the logging function
    }
    "level": Log level, e.g., DEBUG, VERBOSE, etc.
    "message": Actual text of the log message
  }
}

ASTERISK-25425 #close

Change-Id: I8649bfedf3fb7bf3138008cc11565553209cc238
2015-09-29 07:28:01 -05:00
Matt Jordan df7cfc9ac9 Merge "translate: Fix transcoding while different in frame size." 2015-09-28 16:24:19 -05:00
Joshua Colp 6392fdf6dc Merge "logger: Prevent duplicate dynamic channels from being added." 2015-09-25 10:57:40 -05:00
Mark Michelson 3eefa07a39 logger: Prevent duplicate dynamic channels from being added.
There was a problem observed where the "logger add channel" CLI command
would allow for a channel with the same name to be added multiple times.
This would result in each message being written out to the same file
multiple times.

The problem was due to the difference in how logger channel filenames
are stored versus the format they are allowed to be presented when they
are added. For instance, if adding the logger channel "foo" through the
CLI, the result would be a logger channel with the file name
/var/log/asterisk/foo being stored. So when trying to add another "foo"
channel, "foo" would not match "/var/log/asterisk/foo" so we'd happily
add the duplicate channel.

The fix presented here is to introduce two new methods in the logger
code:
 * make_filename(): given a logger channel name, this creates the
   filename for that logger channel.
 * find_logchannel(): given a logger channel name, this calls
   make_filename() and then traverses the list of logchannels in order
   to find a match.

This change has made use of make_filename() and find_logchannel()
throughout to more consistently behave.

ASTERISK-25305 #close
Reported by Mark Michelson

Change-Id: I892d52954d6007d8bc453c3cbdd9235dec9c4a36
2015-09-24 15:05:13 -05:00
Mark Michelson f42084be09 Do not swallow frames on channels leaving bridges.
When leaving a bridge, indications on a channel could be swallowed by
the internal indication logic because it appears that the channel is on
its way to be hung up anyway. One such situation where this is
detrimental is when channels on hold are redirected out of a bridge. The
AST_CONTROL_UNHOLD indication from the bridging code is swallowed,
leaving the channel in question to still appear to be on hold.

The fix here is to modify the logic inside ast_indicate_data() to not
drop the indication if the channel is simply leaving a bridge. This way,
channels on hold redirected out of a bridge revert to their expected "in
use" state after the redirection.

ASTERISK-25418 #close
Reported by Mark Michelson

Change-Id: If6115204dfa0551c050974ee138fabd15f978949
2015-09-24 15:00:27 -05:00
Matt Jordan 6f719bb4d0 Merge "ARI: Add events for Contact and Peer Status changes" 2015-09-23 12:56:26 -05:00
Richard Mudgett 06f4f80a63 app_page.c: Fix crash when forwarding with a predial handler.
Page uses the async method of dialing with the dial API.  When a call gets
forwarded there is no calling channel available.  If the predial handler
was set then the calling channel could not be put into auto-service
for the forwarded call because it doesn't exist.  A crash is the result.

* Moved the callee predial parameter string processing to before the
string is passed to the dial API rather than having the dial API do it.
There are a few benefits do doing this.  The first is the predial
parameter string processing doesn't need to be done for each channel
called by the dial API.  The second is in async mode and the forwarded
channel is to have the predial handler executed on it then the
non-existent calling channel does not need to be present to process the
predial parameter string.

* Don't start auto-service on a non-existent calling channel to execute
the predial handler when the dial API is in async mode and forwarding a
call.

ASTERISK-25384 #close
Reported by: Chet Stevens

Change-Id: If53892b286d29f6cf955e2545b03dcffa2610981
2015-09-22 17:32:03 -05:00
Matt Jordan 069813db3c Merge "core/logging: Fix logging to more than one syslog channel" 2015-09-22 13:20:40 -05:00
Joshua Colp 4effba0d0a Merge "pbx: Update device and presence state when changing a hint extension." 2015-09-22 05:29:52 -05:00
Joshua Colp 4c2b77618c Merge "astfd: Adds a timestamp for each entry." 2015-09-21 08:43:45 -05:00
Elazar Broad a29cf45c76 core/logging: Fix logging to more than one syslog channel
Currently, Asterisk will log to the last configured syslog
channel in logger.conf. This is due to the fact that the
final call to openlog() supersedes all of the previous calls.
This commit removes the call to openlog() and passes the
facility to ast_log_vsyslog(), along with utilizing the
LOG_MAKEPRI macro to ensure that the message is routed to
the correct facility and with the correct priority.

ASTERISK-25407 #close
Reported by: Elazar Broad
Tested by: Elazar Broad

Change-Id: Ie2a2416bc00cce1b04e99ef40917c2011953ddd2
2015-09-21 08:37:06 -05:00
Matt Jordan 5206aa9d30 ARI: Add events for Contact and Peer Status changes
This patch adds support for receiving events regarding Peer status changes
and Contact status changes. This is particularly useful in scenarios where
we are subscribed to all endpoints and channels, where we often want to know
more about the state of channel technology specific items than a single
endpoint's state.

ASTERISK-24870

Change-Id: I6137459cdc25ce27efc134ad58abf065653da4e9
2015-09-21 08:21:58 -05:00
Matt Jordan 5541c6de6e Merge "main/config_options: Check for existance of internal object before derefing" 2015-09-21 08:08:36 -05:00
Alexander Traud 9200ad03a3 astfd: Adds a timestamp for each entry.
Now with menuselect "DEBUG_FD_LEAKS" and CLI "core show fd", a timestamp is
shown with each file descriptor. This helps to debug leaked UDP/TCP ports on
long-lived servers, for example.

ASTERISK-25405 #close

Change-Id: I968339e5155a512eba1032a5263f1ec8b5e1f80b
2015-09-19 19:52:36 +02:00