]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
handle app_lock properly
authorMark Spencer <markster@digium.com>
Tue, 26 Aug 2003 04:53:49 +0000 (04:53 +0000)
committerMark Spencer <markster@digium.com>
Tue, 26 Aug 2003 04:53:49 +0000 (04:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1439 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index ef9fac05be6aad043a6ca6ed0d6d6dbc84b87e67..39f2cbac252ebdbdc5ed3b763dbc5f22f780581a 100755 (executable)
@@ -557,14 +557,13 @@ static int agent_ack_sleep( void *data )
                                break;
                        }
                        ast_mutex_lock(&p->lock);
-                       if (p->app_sleep_cond) {
+                       if (!p->app_sleep_cond) {
                                ast_mutex_unlock(&p->lock);
                                res = 0;
                                break;
                        } else if (res == '#') {
-                               check_availability(p, 0);
                                ast_mutex_unlock(&p->lock);
-                               res = 0;
+                               res = 1;
                                break;
                        }
                        ast_mutex_unlock(&p->lock);
@@ -1218,12 +1217,17 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                ast_mutex_lock(&p->lock);
                                                                p->owning_app = pthread_self();
                                                                ast_mutex_unlock(&p->lock);
-                                                               if (p->ackcall > 1)
+                                                               if (p->ackcall > 1) 
                                                                        res = agent_ack_sleep(p);
                                                                else
                                                                        res = ast_safe_sleep_conditional( chan, 1000,
-                                                                                                               agent_cont_sleep, p );
+                                                                                                       agent_cont_sleep, p );
                                                                ast_mutex_unlock( &p->app_lock );
+                                                               if ((p->ackcall > 1)  && (res == 1)) {
+                                                                       ast_mutex_lock(&p->lock);
+                                                                       check_availability(p, 0);
+                                                                       ast_mutex_unlock(&p->lock);
+                                                               }
                                                                sched_yield();
                                                        }
                                                        ast_mutex_lock(&p->lock);