]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Avoid output of junk text by fs_cli
authorTravis Cross <tc@traviscross.com>
Tue, 26 Aug 2014 18:41:01 +0000 (18:41 +0000)
committerTravis Cross <tc@traviscross.com>
Tue, 26 Aug 2014 20:18:22 +0000 (20:18 +0000)
In some cases where `redisplay()` is called immediately after a
command is run (e.g. `log ...`) we often get a prompt, junk output,
and a second prompt.  This is due to a (known) race.

We believe we're falling afoul of this code in `el_deletestr`:

    if (el->el_line.cursor < &el->el_line.buffer[n])
            return;

Basing the length of text to delete off of the cursor position
resolves the issue of junk text, but the real solution is to eliminate
the race conditions, which will also resolve the sometimes duplicated
prompt.

FS-6764 #resolve

Thanks-to: Nathan Neulinger <nneul@neulinger.org>
libs/esl/fs_cli.c

index ed59792771ed09b6c831d8be96e3b1d65691ad9b..43c186b728cef91647e8a7e3d3ba9c4093a9ecfd 100644 (file)
@@ -1284,7 +1284,7 @@ static void read_config(const char *dft_cfile, const char *cfile) {
 static void clear_el_buffer(void) {
 #ifdef HAVE_LIBEDIT
        const LineInfo *lf = el_line(el);
-       int len = (int)(lf->lastchar - lf->buffer);
+       int len = (int)(lf->cursor - lf->buffer);
        if (global_profile->batch_mode) return;
        el_deletestr(el, len);
        memset((char*)lf->buffer, 0, len);