Fix silly read problem which would hang up if nobody called (bug #3042)
[asterisk/asterisk.git] / apps / app_read.c
index 103e857..e915138 100755 (executable)
@@ -103,9 +103,13 @@ static int read_exec(struct ast_channel *chan, void *data)
        if (!res) {
                ast_stopstream(chan);
                res = ast_app_getdata(chan, filename, tmp, maxdigits, 0);
-               if (res > -1)
+               if (res > -1) {
                        pbx_builtin_setvar_helper(chan, varname, tmp);
-               ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
+                       ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
+                       res = 0;
+               } else {
+                       ast_verbose(VERBOSE_PREFIX_3 "User disconnected\n");
+               }
        }
        LOCAL_USER_REMOVE(u);
        return res;