Just to be especially nice, only send 100 Trying at the start of parking and don...
authorMark Spencer <markster@digium.com>
Fri, 9 Jul 2004 22:43:15 +0000 (22:43 +0000)
committerMark Spencer <markster@digium.com>
Fri, 9 Jul 2004 22:43:15 +0000 (22:43 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3417 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 6fb2909..925d6ff 100755 (executable)
@@ -6631,28 +6631,36 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
 struct sip_dual {
        struct ast_channel *chan1;
        struct ast_channel *chan2;
+       struct sip_request req;
 };
 
 static void *sip_park_thread(void *stuff)
 {
        struct ast_channel *chan1, *chan2;
        struct sip_dual *d;
+       struct sip_pvt *p;
+       struct sip_request req;
        int ext;
        int res;
        d = stuff;
        chan1 = d->chan1;
        chan2 = d->chan2;
+       copy_request(&req, &d->req);
        free(d);
        ast_mutex_lock(&chan1->lock);
        ast_do_masquerade(chan1);
        ast_mutex_unlock(&chan1->lock);
        res = ast_park_call(chan1, chan2, 0, &ext);
+       /* Finally send the accepted */
+       p = chan2->pvt->pvt;
+       transmit_response(p, "202 Accepted", &req);
+       /* Then hangup */
        ast_hangup(chan2);
        ast_log(LOG_DEBUG, "Parked on extension '%d'\n", ext);
        return NULL;
 }
 
-static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2)
+static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req)
 {
        struct sip_dual *d;
        struct ast_channel *chan1m, *chan2m;
@@ -6699,6 +6707,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2)
        d = malloc(sizeof(struct sip_dual));
        if (d) {
                memset(d, 0, sizeof(*d));
+               /* Save original request for followup */
+               copy_request(&d->req, req);
                d->chan1 = chan1m;
                d->chan2 = chan2m;
                if (!pthread_create(&th, NULL, sip_park_thread, d))
@@ -7033,7 +7043,6 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                        transmit_response_with_allow(p, "484 Address Incomplete", req, 1);
                else {
                        int nobye = 0;
-                       transmit_response(p, "202 Accepted", req);
                        if (!ignore) {
                                if (p->refer_call) {
                                        ast_log(LOG_DEBUG,"202 Accepted (supervised)\n");
@@ -7051,11 +7060,13 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                                if (transfer_to) {
                                                        ast_moh_stop(transfer_to);
                                                        if (!strcmp(p->refer_to, ast_parking_ext())) {
+                                                               /* We send a 100 Trying */
+                                                               transmit_response(p, "100 Trying", req);
                                                                /* Must release c's lock now, because it will not longer
                                                                    be accessible after the transfer! */
                                                                *nounlock = 1;
                                                                ast_mutex_unlock(&c->lock);
-                                                               sip_park(transfer_to, c);
+                                                               sip_park(transfer_to, c, req);
                                                                nobye = 1;
                                                        } else {
                                                                /* Must release c's lock now, because it will not longer
@@ -7072,6 +7083,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                }
                                /* Always increment on a BYE */
                                if (!nobye) {
+                                       transmit_response(p, "202 Accepted", req);
                                        transmit_request_with_auth(p, "BYE", 0, 1, 1);
                                        p->alreadygone = 1;
                                }