asterisk/apps
David Vossel 776a14386a SIP TCP/TLS: move client connection setup/write into tcp helper thread, various related locking/memory fixes.
What this patch fixes
1.Moves sip TCP/TLS connection setup into the TCP helper thread:
  Connection setup takes awhile and before this it was being
  done while holding the monitor lock.
2.Moves TCP/TLS writing to the TCP helper thread:  Through the
  use of a packet queue and an alert pipe, the TCP helper thread
  can now be woken up to write data as well as read data.
3.Locking error: sip_xmit returned an XMIT_ERROR without giving
  up the tcptls_session lock.  This lock has been completely removed
  from sip_xmit and placed in the new sip_tcptls_write() function.
4.Memory leak:  When creating a tcptls_client the tls_cfg was alloced
  but never freed unless the tcptls_session failed to start.  Now the
  session_args for a sip client are an ao2 object which frees the
  tls_cfg on destruction.
5.Pointer to stack variable: During sip_prepare_socket the creation
  of a client's ast_tcptls_session_args was done on the stack and
  stored as a pointer in the newly created tcptls_session.  Depending
  on the events that followed, there was a slight possibility that
  pointer could have been accessed after the stack returned.  Given
  the new changes, it is always accessed after the stack returns
  which is why I found it.

Notable code changes
1.I broke tcptls.c's ast_tcptls_client_start() function into two
  functions.  One for creating and allocating the new tcptls_session,
  and a separate one for starting and handling the new connection.
  This allowed me to create the tcptls_session, launch the helper
  thread, and then establish the connection within the helper thread.
2.Writes to a tcptls_session are now done within the helper thread.
  This is done by using an alert pipe to wake up the thread if new
  data needs to be sent.  The thread's sip_threadinfo object contains
  the alert pipe as well as the packet queue.
3.Since the threadinfo object contains the alert pipe, it must now be
  accessed outside of the helper thread for every write (queuing of a
  packet).  For easy lookup, I moved the threadinfo objects from a
  linked list to an ao2_container.

(closes issue #13136)
Reported by: pabelanger
Tested by: dvossel, whys

(closes issue #15894)
Reported by: dvossel
Tested by: dvossel

Review: https://reviewboard.asterisk.org/r/380/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@225445 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-22 19:55:51 +00:00
..
Makefile One of the changes in 1.6.1 was to allow app_directory to use functionality 2009-06-18 20:52:36 +00:00
app_adsiprog.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_alarmreceiver.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_amd.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_authenticate.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_cdr.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_celgenuserevent.c Merge the new Channel Event Logging (CEL) subsystem. 2009-06-26 15:28:53 +00:00
app_chanisavail.c Merge the new Channel Event Logging (CEL) subsystem. 2009-06-26 15:28:53 +00:00
app_channelredirect.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_chanspy.c Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ast_channel_iterator to use it. 2009-10-21 21:08:47 +00:00
app_confbridge.c Fix options 'm' and 's'. They were swapped in the code. Also document the fact that app_confbridge does not automatically answer the channel. 2009-09-29 19:49:02 +00:00
app_controlplayback.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_dahdibarge.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_dahdiras.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_db.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_dial.c Merged revisions 224565 via svnmerge from 2009-10-19 19:49:09 +00:00
app_dictate.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_directed_pickup.c Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ast_channel_iterator to use it. 2009-10-21 21:08:47 +00:00
app_directory.c Fix two possible crashes, one only in 1.6.1 and one in 1.6.1 forward. 2009-09-24 07:39:44 +00:00
app_disa.c Merged revisions 220288 via svnmerge from 2009-09-24 19:41:02 +00:00
app_dumpchan.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_echo.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_exec.c Global var cleanup - constification and removing unused vars. 2009-06-07 14:55:51 +00:00
app_externalivr.c SIP TCP/TLS: move client connection setup/write into tcp helper thread, various related locking/memory fixes. 2009-10-22 19:55:51 +00:00
app_fax.c Remove automatic switching from T.38 to voice mode in chan_sip. 2009-10-12 14:25:29 +00:00
app_festival.c Restore an int declaration on PPC platforms. 2009-07-22 21:43:57 +00:00
app_flash.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_followme.c Merged revisions 218577 via svnmerge from 2009-09-15 16:04:41 +00:00
app_forkcdr.c Fixes numerous spelling errors. Patch submitted by alecdavis. 2009-07-30 16:07:05 +00:00
app_getcpeid.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_ices.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_image.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_ivrdemo.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_jack.c minor tweak 2009-06-06 21:42:31 +00:00
app_macro.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_meetme.c Merged revisions 225105 via svnmerge from 2009-10-22 17:11:23 +00:00
app_milliwatt.c Merged revisions 209838 via svnmerge from 2009-08-01 11:02:07 +00:00
app_minivm.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_mixmonitor.c Merged revisions 213103 via svnmerge from 2009-08-19 21:21:00 +00:00
app_morsecode.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_mp3.c Fix constify the world compile problem. 2009-05-22 15:07:48 +00:00
app_nbscat.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_originate.c Revert inadvertant code commit to app_originate 2009-10-13 01:58:09 +00:00
app_osplookup.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_page.c Last batch of 'static' qualifiers for module-level global variables. 2009-06-15 19:10:10 +00:00
app_parkandannounce.c Merge the new Channel Event Logging (CEL) subsystem. 2009-06-26 15:28:53 +00:00
app_playback.c Merged revisions 220288 via svnmerge from 2009-09-24 19:41:02 +00:00
app_playtones.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_privacy.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_queue.c Recorded merge of revisions 222152 via svnmerge from 2009-10-06 01:24:24 +00:00
app_read.c Last batch of 'static' qualifiers for module-level global variables. 2009-06-15 19:10:10 +00:00
app_readexten.c Last batch of 'static' qualifiers for module-level global variables. 2009-06-15 19:10:10 +00:00
app_readfile.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_record.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_rpt.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_sayunixtime.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_senddtmf.c Implement a new element in AstXML for AMI actions documentation. 2009-05-22 17:52:35 +00:00
app_sendtext.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_setcallerid.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_skel.c Last batch of 'static' qualifiers for module-level global variables. 2009-06-15 19:10:10 +00:00
app_sms.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_softhangup.c Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ast_channel_iterator to use it. 2009-10-21 21:08:47 +00:00
app_speech_utils.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_stack.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_system.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_talkdetect.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_test.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_transfer.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_url.c Last batch of 'static' qualifiers for module-level global variables. 2009-06-15 19:10:10 +00:00
app_userevent.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_verbose.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_voicemail.c Permit storage of voicemail secrets in a separate file, located within the spool directory. 2009-10-22 19:10:04 +00:00
app_voicemail.exports Merged revisions 213283 via svnmerge from 2009-08-20 19:56:14 +00:00
app_waitforring.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_waitforsilence.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_waituntil.c AST-2009-005 2009-08-10 19:20:57 +00:00
app_while.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
app_zapateller.c Const-ify the world (or at least a good part of it) 2009-05-21 21:13:09 +00:00
enter.h remove extraneous svn:executable properties 2005-11-29 18:24:39 +00:00
leave.h remove extraneous svn:executable properties 2005-11-29 18:24:39 +00:00
rpt_flow.pdf remove extraneous svn:executable properties 2005-11-29 18:24:39 +00:00