[Home]

Summary:ASTERISK-12321: [patch] Remove the 500ms delay trying to receive all CLI command output.
Reporter:Eliel Sardanons (eliel)Labels:
Date Opened:2008-07-06 01:43:02Date Closed:2008-07-08 15:09:47
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20080708__bug13001.diff.txt
( 1) 20080708__bug13001.diff.txt.fixed
( 2) asteriskrx.patch
( 3) rasterisk.patch
Description:I found this way to fix the 500ms delay in the polling that was increasing the execution time of a 'asterisk -rx' command.
I created a command '_command nextislast' that is executed when 'asterisk -rx' is being used to connect to the asterisk socket, and this command tells asterisk that the next command within that console is the last, so now asterisk is the responsible for closing the socket and we just wait for all the output forever until the socket is closed.
Comments:By: Tilghman Lesher (tilghman) 2008-07-06 08:42:27

Just idly wondering... would this be easier to do if we created a prefix instead of a separate command... for example, "cli quit after core show channels", where the "cli quit after" was intercepted by the command interpreter and the remaining arguments passed.  I'm suggesting this prefix to keep with our "<module> <action> <args>" syntax.  This would also simplify the implementation.

Not saying you have to do it this way, just looking at the problems that this approach has and trying to come up with a better way:

I understand your approach with trying to have an output for your command, but this is not backwards compatible:  it adds another bit of output that needs to be removed by what is running the command (negating part of the reason the delay was put in there in the first place: to get rid of extraneous output).  The output, if this approach remains, should also be an English phrase, not the cryptic "nextislast\n" anyway.

By: Eliel Sardanons (eliel) 2008-07-06 10:41:38

I like your idea, just one question to start writing the mods:
Do you think that this CLI command (cli quit after) should be implemented in main/cli.c or in main/asterisk.c. I need access to 'consoles' so if we creates in main/asterisk.c we don't need to create a function to access 'consoles', but in the other way I need to create that function (like I did in the submitted patch). Also if your answer is to put this command in main/cli.c, where I should put the function definition? in include/asterisk/cli.h? Like I did in the uploaded patch? I couldn't find a nice place.

Thanks in advance

By: Tzafrir Cohen (tzafrir) 2008-07-06 14:10:14

The time to wait is only a matter for the remote console to decide.

e.g: there could be an extra switch telling "I don't care about the output, so don't wait at all" or a similar semantics.

By: Eliel Sardanons (eliel) 2008-07-06 18:01:46

With this new CLI command, the remote console will be able to
close the connection at the exact moment that we finish receiving the command output, and this was the issue that we didn't know how much time to wait after receiving all the output, but:
if the remote console wants to continue connected will be able by just running the normal commands, if it wants to loose the output is allow to close the socket at any time also. So this situations are allow,  and are handled by the remote console, we are giving this new command for the clients that want to run a command, receive the output and disconnect inmediatly.

By: Eliel Sardanons (eliel) 2008-07-06 22:18:11

asteriskrx.patch implements cli command 'cli quit after' that runs a cli command and then disconnects from the cli. This command is the one used by 'asterisk -rx' for running CLI commands and show the output.

By: Tzafrir Cohen (tzafrir) 2008-07-07 01:25:31

Again, this is only relevant to the remote terminal. The main asterisk process does not need to know how much the remote process has waited. Adding it as a command means that this affects command-line completion.

But this command is not relevant to a local console (asterisk -c) or to the Command manager command (astcli).

By: Eliel Sardanons (eliel) 2008-07-07 08:59:45

what if we hide this command with "_" like i did in the first patch? (a mix) I continue thinking that this is better (giving a solution to every client to know when output finish) than having a 500ms timeout while running asterisk -rx and don't be sure that the output will come up.

By: Tilghman Lesher (tilghman) 2008-07-08 12:23:53

This can be done much simpler.  Patch uploaded.

By: Eliel Sardanons (eliel) 2008-07-08 14:27:06

Sorry, for removing my notes and the first patch...
The real problem with your patch was the size of the command being passed to ast_cli_command_multiple, should be: res-15.

Patch uploaded.

By: Digium Subversion (svnbot) 2008-07-08 15:09:43

Repository: asterisk
Revision: 129114

U   trunk/main/asterisk.c

------------------------------------------------------------------------
r129114 | tilghman | 2008-07-08 15:09:42 -0500 (Tue, 08 Jul 2008) | 8 lines

Reduce length of time that 'asterisk -rx' waits.
(closes issue ASTERISK-12321)
Reported by: eliel
Patches:
      20080708__bug13001.diff.txt uploaded by Corydon76 (license 14)
      20080708__bug13001.diff.txt.fixed uploaded by eliel (license 64)
Tested by: Corydon76, eliel

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=129114