add ActionID output and lock CLI fd for Manager action DBGet (bug #4727)
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 20 Jul 2005 00:38:20 +0000 (00:38 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 20 Jul 2005 00:38:20 +0000 (00:38 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6175 65c4cc65-6c06-0410-ace0-fbb531ad65f3

db.c

diff --git a/db.c b/db.c
index 707f57e..0e46604 100755 (executable)
--- a/db.c
+++ b/db.c
@@ -529,6 +529,8 @@ static int manager_dbput(struct mansession *s, struct message *m)
 
 static int manager_dbget(struct mansession *s, struct message *m)
 {
+       char *id = astman_get_header(m,"ActionID");
+       char idText[256] = "";
        char *family = astman_get_header(m, "Family");
        char *key = astman_get_header(m, "Key");
        char tmp[256];
@@ -543,16 +545,23 @@ static int manager_dbget(struct mansession *s, struct message *m)
                return 0;
        }
 
+       if (id && !ast_strlen_zero(id))
+               snprintf(idText, sizeof(idText) ,"ActionID: %s\r\n", id);
+
        res = ast_db_get(family, key, tmp, sizeof(tmp));
        if (res) {
                astman_send_error(s, m, "Database entry not found");
        } else {
                astman_send_ack(s, m, "Result will follow");
+               ast_mutex_lock(&s->lock);
                ast_cli(s->fd, "Event: DBGetResponse\r\n"
                                "Family: %s\r\n"
                                "Key: %s\r\n"
-                               "Val: %s\r\n\r\n",
-                               family, key, tmp);
+                               "Val: %s\r\n"
+                               "%s"
+                               "\r\n",
+                               family, key, tmp, idText);
+               ast_mutex_unlock(&s->lock);
        }
        return 0;
 }