[asterisk-dev] [Code Review] 2507: Add support for indexing installed sounds and for Stasis-HTTP sounds queries

David Lee reviewboard at asterisk.org
Mon Jun 3 14:46:12 CDT 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2507/#review8771
-----------------------------------------------------------


Nothing major, but a lot of little things.


trunk/include/asterisk/file.h
<https://reviewboard.asterisk.org/r/2507/#comment17212>

    add /since 12



trunk/include/asterisk/media_index.h
<https://reviewboard.asterisk.org/r/2507/#comment17220>

    Would it be bad if the string were ao2_alloc()'ed, so it could be ref-counted instead of copied?



trunk/include/asterisk/media_index.h
<https://reviewboard.asterisk.org/r/2507/#comment17221>

    With what function? ast_free(), ao2_cleanup() or other?



trunk/include/asterisk/media_index.h
<https://reviewboard.asterisk.org/r/2507/#comment17213>

    Wouldn't it be better to put the base_dir and variant in the constructor rather than in index_update()? Otherwise we've got to know the proper base_dir and varient from every place where we might want to kick off an index update.



trunk/include/asterisk/sounds_index.h
<https://reviewboard.asterisk.org/r/2507/#comment17214>

    Comment that returned index should be ao2_cleanup()'ed.



trunk/main/file.c
<https://reviewboard.asterisk.org/r/2507/#comment17215>

    The append could also fail. Since the calls are NULL safe and reference stealing, call chaining is encouraged.
    
      int res = ast_json_array_append(array, ast_json_string_create(ext));
    
      if (res != 0) {
        return NULL;
      }



trunk/main/file.c
<https://reviewboard.asterisk.org/r/2507/#comment17216>

    You can safely inline the ref call:
      return ast_json_ref(array);



trunk/main/media_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17217>

    Test variant for allocation failure.



trunk/main/media_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17218>

    Test info for allocation failure.



trunk/main/media_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17219>

    Test index for allocation failure.



trunk/main/media_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17225>

    fstatat has some portability problems. See http://www.gnu.org/software/gnulib/manual/html_node/fstatat.html



trunk/main/media_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17223>

    You should check the results of media_index_update and fail if it returns non-zero.



trunk/main/sounds_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17224>

    Idem.



trunk/main/sounds_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17228>

    This could have race conditions if multiple reindexes happen from different thread simultaneously.
    
    You also may have to lock access to sounds_index, if only to setup a memory fence.



trunk/main/sounds_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17229>

    A reindex will take the sounds pointer out from under us. It should be captured in a local variable and refcounted.



trunk/main/sounds_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17230>

    spacing between show and the [



trunk/main/sounds_index.c
<https://reviewboard.asterisk.org/r/2507/#comment17231>

    unsubscribe_and_join()



trunk/res/stasis_http/resource_sounds.c
<https://reviewboard.asterisk.org/r/2507/#comment17234>

    Why the strdupa?


- David Lee


On May 24, 2013, 3:31 p.m., opticron wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2507/
> -----------------------------------------------------------
> 
> (Updated May 24, 2013, 3:31 p.m.)
> 
> 
> Review request for Asterisk Developers and David Lee.
> 
> 
> Bugs: ASTERISK-21584 and ASTERISK-21585
>     https://issues.asterisk.org/jira/browse/ASTERISK-21584
>     https://issues.asterisk.org/jira/browse/ASTERISK-21585
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> This adds support for stasis/sounds and stasis/sounds/{ID} queries via the Stasis-HTTP interface.
> 
> The following changes have been made to accomplish this:
> * A modular indexer was created for local media.
> * A new function to get an ast_format associated with a file extension was added.  
> * Modifications were made to the built-in HTTP server so that URI decoding could be deferred to the URI handler when necessary.
> * The Stasis-HTTP sounds JSON documentation was modified to handle cases where multiple languages are installed in different formats.
> * Register and Unregister events for formats were added to the system topic.
> 
> 
> Diffs
> -----
> 
>   trunk/include/asterisk/_private.h 389730 
>   trunk/include/asterisk/file.h 389730 
>   trunk/include/asterisk/format.h 389730 
>   trunk/include/asterisk/http.h 389730 
>   trunk/include/asterisk/media_index.h PRE-CREATION 
>   trunk/include/asterisk/sounds_index.h PRE-CREATION 
>   trunk/main/asterisk.c 389730 
>   trunk/main/file.c 389730 
>   trunk/main/http.c 389730 
>   trunk/main/media_index.c PRE-CREATION 
>   trunk/main/sounds_index.c PRE-CREATION 
>   trunk/res/res_stasis_http.c 389730 
>   trunk/res/stasis_http/resource_sounds.c 389730 
>   trunk/rest-api/api-docs/sounds.json 389730 
> 
> Diff: https://reviewboard.asterisk.org/r/2507/diff/
> 
> 
> Testing
> -------
> 
> Tested using a browser and HTTP GET requests using the Stasis-HTTP API.  Currently contemplating how to create automated tests.
> 
> 
> Thanks,
> 
> opticron
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130603/44b0810c/attachment-0001.htm>


More information about the asterisk-dev mailing list