Index: src/mod/applications/mod_fifo/mod_fifo.c
===================================================================
--- src/mod/applications/mod_fifo/mod_fifo.c    (revision 7959)
+++ src/mod/applications/mod_fifo/mod_fifo.c    (revision 7957)
@@ -337,7 +337,10 @@ SWITCH_STANDARD_APP(fifo_function)
        int custom_pop = 0;
        int pop_array[MAX_PRI] = { 0 };
        char *pop_list[MAX_PRI] = { 0 };
-       
+       const char *fifo_consumer_wrapup_sound = NULL;
+       const char *fifo_consumer_wrapup_key = NULL;
+       char buf[5] = "";
+
         if (argc > 3) {
             announce = argv[3];
         }
@@ -379,15 +382,17 @@ SWITCH_STANDARD_APP(fifo_function)
            }
 
            for (x = 0; x < custom_pop; x++) {
-               int temp = atoi(pop_list[x]);
-               if (temp > -1 && temp < MAX_PRI) {
-                   pop_array[x] = temp;
+               int tmp = atoi(pop_list[x]);
+               if (tmp > -1 && tmp < MAX_PRI) {
+                   pop_array[x] = tmp;
                }
            }
        }
        
        while(switch_channel_ready(channel)) {
            int x = 0 ;
+           pop = NULL;
+
             if (moh) {
                 args.read_frame_callback = read_frame_callback;
                 args.user_data = node;
@@ -423,6 +428,7 @@ SWITCH_STANDARD_APP(fifo_function)
             }
            
             uuid = (char *) pop;
+           pop = NULL;
 
             if ((other_session = switch_core_session_locate(uuid))) {
                 switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
@@ -505,6 +511,28 @@ SWITCH_STANDARD_APP(fifo_function)
                 if (nowait) {
                     done = 1;
                 }
+
+               fifo_consumer_wrapup_sound = switch_channel_get_variable(channel, "fifo_consumer_wrapup_sound");
+               fifo_consumer_wrapup_key = switch_channel_get_variable(channel, "fifo_consumer_wrapup_key");
+               memset(buf, 0, sizeof(buf));
+
+               if (!switch_strlen_zero(fifo_consumer_wrapup_sound)) {
+                   args.buf = buf;
+                   args.buflen = sizeof(buf);
+                   
+                   memset(&args, 0, sizeof(args));
+                   switch_ivr_play_file(session, NULL, fifo_consumer_wrapup_sound, &args);
+               }
+
+               if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) {
+                   for(;;) {
+                       char terminator = 0;                        
+                       switch_ivr_collect_digits_count(session, buf, sizeof(buf)-1, 1, fifo_consumer_wrapup_key, &terminator, 0, 0, 0);
+                       if (terminator == *fifo_consumer_wrapup_key) {
+                           break;
+                       }
+                   }
+               }
             }
 
             switch_safe_free(uuid);
@@ -672,12 +700,12 @@ SWITCH_STANDARD_API(fifo_api_function)
     } else if (!strcasecmp(argv[0], "count")) {
         if (argc < 2) {
             for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
-               int i = 0;
+               int x = 0;
                 switch_hash_this(hi, &var, NULL, &val);
                 node = (fifo_node_t *) val;
                len = 0;
-               for (i = 0; i < MAX_PRI; i++) {
-                   len += switch_queue_size(node->fifo_list[i]);
+               for (x = 0 ;x < MAX_PRI; x++) {
+                   len += switch_queue_size(node->fifo_list[x]);
                }
                 switch_mutex_lock(node->mutex);
                 stream->write_function(stream, "%s:%d:%d:%d\n", (char *)var, node->consumer_count, node->caller_count, len);
@@ -690,10 +718,10 @@ SWITCH_STANDARD_API(fifo_api_function)
             }
         } else {
             if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
-               int i = 0;
+               int x = 0;
                len = 0;
-               for (i = 0 ;i < MAX_PRI; i++) {
-                    len += switch_queue_size(node->fifo_list[i]);
+               for (x = 0 ;x < MAX_PRI; x++) {
+                    len += switch_queue_size(node->fifo_list[x]);
                 }
                
             }
