On Fri, 23 Dec 2005, Armin Schindler wrote:
> Hi all,
> 
> I think I found the problem why the transcodec does not work all the time.
> 
> The problem is the new generator thread:
> 
>   when opbx_generator_deactivate() is called, the ongoing code expects
>   the generator to be really deactivated and everything cleaned up.
>   But since the real deactivation is done in the thread itself, its 
>   execution will be delayed.
> 
>   This means for example in corelib/indications.c the function
>    static void playtones_release(struct opbx_channel *chan, void *params)
>    {
>         struct playtones_state *ps = params;
>         if (chan) {
>                 opbx_set_write_format(chan, ps->origwfmt);
>         }
>         if (ps->items) free(ps->items);
>         free(ps);
>    } 
>   will be executed after opbx_channel_make_compatible() and the
>   writeformat is re-changed to a wrong setting.
> 
> The following patch fixes that, but it is not a nice solution. Maybe the 
> originator of the channel.c/generator.c split-off can have a look at this.
> 
> Until there is a better idea, I will commit this patch to make OpenPBX 
> work again.
> 
> Armin
> 
> 
> --- OpenPBX.orig/corelib/generator.c  2005-11-18 04:31:40.000000000 +0100
> +++ OpenPBX/corelib/generator.c       2005-12-23 16:32:31.611838655 +0100
> @@ -164,6 +131,8 @@
>       pgcd->gen_req = gen_req_deactivate;
>       opbx_cond_signal(&pgcd->gen_req_cond);
>       opbx_mutex_unlock(&pgcd->lock);
> +     while (opbx_generator_is_active(chan))
> +             usleep(1000);
>  }

There is a deadlock when waiting for generator deactivation. It seems
opbx_generator_deactivate() is called with some lock held some times and the 
release function (called by the generator thread) also tries to lock the 
same one (chan->lock).
The following patch is a workaround for the deadlock, but all the generator 
stuff must be re-visited.
Is anyone beside me interesed in get a working OpenPBX ?

Armin

diff -u -r OpenPBX.orig/corelib/channel.c OpenPBX/corelib/channel.c
--- OpenPBX.orig/corelib/channel.c      2005-12-27 16:49:34.755659680 +0100
+++ OpenPBX/corelib/channel.c   2005-12-27 16:51:07.659577052 +0100
@@ -1948,7 +1948,6 @@
        }
        
        /* Now we have a good choice for both. */
-       opbx_mutex_lock(&chan->lock);
        *rawformat = native;
        /* User perspective is fmt */
        *format = fmt;
@@ -1962,7 +1961,6 @@
        else
                /* writing */
                *trans = opbx_translator_build_path(*rawformat, *format);
-       opbx_mutex_unlock(&chan->lock);
        if (option_debug)
                opbx_log(LOG_DEBUG, "Set channel %s to %s format %s\n", 
chan->name,
                        direction ? "write" : "read", opbx_getformatname(fmt));

_______________________________________________
Openpbx-dev mailing list
[email protected]
http://lists.openpbx.org/mailman/listinfo/openpbx-dev

Reply via email to