Index: include/asterisk/features.h =================================================================== --- include/asterisk/features.h (revision 330704) +++ include/asterisk/features.h (working copy) @@ -119,6 +119,8 @@ /*! \brief Bridge a call, optionally allowing redirection */ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config); +int ast_pickup_active(struct ast_channel *chan); + /*! * \brief Test if a channel can be picked up. * Index: include/asterisk/channelstate.h =================================================================== --- include/asterisk/channelstate.h (revision 330704) +++ include/asterisk/channelstate.h (working copy) @@ -43,7 +43,7 @@ AST_STATE_BUSY, /*!< Line is busy */ AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */ AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */ - + AST_STATE_PICKUP, /*!< iLine is being picked up*/ AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */ }; Index: main/channel.c =================================================================== --- main/channel.c (revision 330704) +++ main/channel.c (working copy) @@ -68,6 +68,7 @@ #include "asterisk/stringfields.h" #include "asterisk/global_datastores.h" #include "asterisk/data.h" +#include "asterisk/features.h" #ifdef HAVE_EPOLL #include @@ -2836,6 +2837,13 @@ chan->generatordata = NULL; chan->generator = NULL; + if (ast_pickup_active(chan)) { + ast_log(LOG_ERROR, "ALEC ==================Pickup active on this channel '%s'=========================\n", chan->name); +// ast_channel_unlock(chan); +// ast_channel_unref(chan); +// return -1; + } + snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), "")); ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL); @@ -2913,6 +2921,7 @@ switch (chan->_state) { case AST_STATE_RINGING: case AST_STATE_RING: + case AST_STATE_PICKUP: ast_channel_lock(chan); if (chan->tech->answer) { res = chan->tech->answer(chan); @@ -2955,6 +2964,7 @@ switch (old_state) { case AST_STATE_RINGING: case AST_STATE_RING: + case AST_STATE_PICKUP: /* wait for media to start flowing, but don't wait any longer * than 'delay' or 500 milliseconds, whichever is longer */ Index: main/features.c =================================================================== --- main/features.c (revision 330704) +++ main/features.c (working copy) @@ -5776,6 +5776,13 @@ .type = "pickup-active", }; +int ast_pickup_active(struct ast_channel *chan) { + if (ast_channel_datastore_find(chan, &pickup_active, NULL)) { + return 1; + } + return 0; +} + int ast_can_pickup(struct ast_channel *chan) { if (!chan->pbx && !chan->masq && !ast_test_flag(chan, AST_FLAG_ZOMBIE) @@ -5789,6 +5796,7 @@ */ || chan->_state == AST_STATE_DOWN) && !ast_channel_datastore_find(chan, &pickup_active, NULL)) { + chan->_state = AST_STATE_PICKUP; return 1; } return 0;