<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -50,8 +50,9 @@
 #define OP_WATCH 12
 #define OP_IGNORE 13
 #define OP_LIST_TUBES 14
-#define OP_LIST_TUBES_WATCHED 15
-#define OP_STATS_TUBE 16
+#define OP_LIST_TUBE_USED 15
+#define OP_LIST_TUBES_WATCHED 16
+#define OP_STATS_TUBE 17
 
 /* CONN_TYPE_* are bit masks */
 #define CONN_TYPE_PRODUCER 1</diff>
      <filename>conn.h</filename>
    </modified>
    <modified>
      <diff>@@ -470,6 +470,12 @@ of strings to scalars. It contains these keys:
 
  - &quot;cmd-reserve&quot; is the cumulative number of reserve commands.
 
+ - &quot;cmd-use&quot; is the cumulative number of use commands.
+
+ - &quot;cmd-watch&quot; is the cumulative number of watch commands.
+
+ - &quot;cmd-ignore&quot; is the cumulative number of ignore commands.
+
  - &quot;cmd-delete&quot; is the cumulative number of delete commands.
 
  - &quot;cmd-release&quot; is the cumulative number of release commands.
@@ -486,6 +492,8 @@ of strings to scalars. It contains these keys:
 
  - &quot;cmd-list-tubes&quot; is the cumulative number of list-tubes commands.
 
+ - &quot;cmd-list-tube-used&quot; is the cumulative number of list-tube-used commands.
+
  - &quot;cmd-list-tubes-watched&quot; is the cumulative number of list-tubes-watched
    commands.
 
@@ -534,6 +542,17 @@ OK &lt;bytes&gt;\r\n
  - &lt;data&gt; is a sequence of bytes of length &lt;bytes&gt; from the previous line. It
    is a YAML file containing all tube names as a list of strings.
 
+The list-tube-used command returns the tube currently being used by the
+client. Its form is:
+
+list-tube-used\r\n
+
+The response is:
+
+USING &lt;tube&gt;\r\n
+
+ - &lt;tube&gt; is the name of the tube being used.
+
 The list-tubes-watched command returns a list tubes currently being watched by
 the client. Its form is:
 </diff>
      <filename>doc/protocol.txt</filename>
    </modified>
    <modified>
      <diff>@@ -58,6 +58,7 @@
 #define CMD_WATCH &quot;watch &quot;
 #define CMD_IGNORE &quot;ignore &quot;
 #define CMD_LIST_TUBES &quot;list-tubes&quot;
+#define CMD_LIST_TUBE_USED &quot;list-tube-used&quot;
 #define CMD_LIST_TUBES_WATCHED &quot;list-tubes-watched&quot;
 #define CMD_STATS_TUBE &quot;stats-tube &quot;
 
@@ -76,6 +77,7 @@
 #define CMD_WATCH_LEN CONSTSTRLEN(CMD_WATCH)
 #define CMD_IGNORE_LEN CONSTSTRLEN(CMD_IGNORE)
 #define CMD_LIST_TUBES_LEN CONSTSTRLEN(CMD_LIST_TUBES)
+#define CMD_LIST_TUBE_USED_LEN CONSTSTRLEN(CMD_LIST_TUBE_USED)
 #define CMD_LIST_TUBES_WATCHED_LEN CONSTSTRLEN(CMD_LIST_TUBES_WATCHED)
 #define CMD_STATS_TUBE_LEN CONSTSTRLEN(CMD_STATS_TUBE)
 
@@ -114,12 +116,16 @@
     &quot;cmd-reserve: %llu\n&quot; \
     &quot;cmd-delete: %llu\n&quot; \
     &quot;cmd-release: %llu\n&quot; \
+    &quot;cmd-use: %llu\n&quot; \
+    &quot;cmd-watch: %llu\n&quot; \
+    &quot;cmd-ignore: %llu\n&quot; \
     &quot;cmd-bury: %llu\n&quot; \
     &quot;cmd-kick: %llu\n&quot; \
     &quot;cmd-stats: %llu\n&quot; \
     &quot;cmd-stats-job: %llu\n&quot; \
     &quot;cmd-stats-tube: %llu\n&quot; \
     &quot;cmd-list-tubes: %llu\n&quot; \
+    &quot;cmd-list-tube-used: %llu\n&quot; \
     &quot;cmd-list-tubes-watched: %llu\n&quot; \
     &quot;job-timeouts: %llu\n&quot; \
     &quot;total-jobs: %llu\n&quot; \
@@ -175,7 +181,8 @@ static unsigned long long int put_ct = 0, peek_ct = 0, reserve_ct = 0,
                      delete_ct = 0, release_ct = 0, bury_ct = 0, kick_ct = 0,
                      stats_job_ct = 0, stats_ct = 0, timeout_ct = 0,
                      list_tubes_ct = 0, stats_tube_ct = 0,
-                     list_watched_tubes_ct = 0;
+                     list_tube_used_ct = 0, list_watched_tubes_ct = 0,
+                     use_ct = 0, watch_ct = 0, ignore_ct = 0;
 
 
 /* Doubly-linked list of connections with at least one reserved job. */
@@ -198,6 +205,7 @@ static const char * op_names[] = {
     CMD_WATCH,
     CMD_IGNORE,
     CMD_LIST_TUBES,
+    CMD_LIST_TUBE_USED,
     CMD_LIST_TUBES_WATCHED,
     CMD_STATS_TUBE,
 };
@@ -634,6 +642,7 @@ which_cmd(conn c)
     TEST_CMD(c-&gt;cmd, CMD_WATCH, OP_WATCH);
     TEST_CMD(c-&gt;cmd, CMD_IGNORE, OP_IGNORE);
     TEST_CMD(c-&gt;cmd, CMD_LIST_TUBES_WATCHED, OP_LIST_TUBES_WATCHED);
+    TEST_CMD(c-&gt;cmd, CMD_LIST_TUBE_USED, OP_LIST_TUBE_USED);
     TEST_CMD(c-&gt;cmd, CMD_LIST_TUBES, OP_LIST_TUBES);
     return OP_UNKNOWN;
 }
@@ -716,12 +725,16 @@ fmt_stats(char *buf, size_t size, void *x)
             reserve_ct,
             delete_ct,
             release_ct,
+            use_ct,
+            watch_ct,
+            ignore_ct,
             bury_ct,
             kick_ct,
             stats_ct,
             stats_job_ct,
             stats_tube_ct,
             list_tubes_ct,
+            list_tube_used_ct,
             list_watched_tubes_ct,
             timeout_ct,
             global_stat.total_jobs_ct,
@@ -1174,6 +1187,15 @@ dispatch_cmd(conn c)
         list_tubes_ct++;
         do_list_tubes(c, &amp;tubes);
         break;
+    case OP_LIST_TUBE_USED:
+        /* don't allow trailing garbage */
+        if (c-&gt;cmd_len != CMD_LIST_TUBE_USED_LEN + 2) {
+            return reply_msg(c, MSG_BAD_FORMAT);
+        }
+
+        list_tube_used_ct++;
+        reply_line(c, STATE_SENDWORD, &quot;USING %s\r\n&quot;, c-&gt;use-&gt;name);
+        break;
     case OP_LIST_TUBES_WATCHED:
         /* don't allow trailing garbage */
         if (c-&gt;cmd_len != CMD_LIST_TUBES_WATCHED_LEN + 2) {
@@ -1193,6 +1215,7 @@ dispatch_cmd(conn c)
         TUBE_ASSIGN(c-&gt;use, t);
         TUBE_ASSIGN(t, NULL);
 
+        use_ct++;
         reply_line(c, STATE_SENDWORD, &quot;USING %s\r\n&quot;, c-&gt;use-&gt;name);
         break;
     case OP_WATCH:
@@ -1207,6 +1230,7 @@ dispatch_cmd(conn c)
         TUBE_ASSIGN(t, NULL);
         if (!r) return reply_serr(c, MSG_OUT_OF_MEMORY);
 
+        watch_ct++;
         reply_line(c, STATE_SENDWORD, &quot;WATCHING %d\r\n&quot;, c-&gt;watch.used);
         break;
     case OP_IGNORE:
@@ -1225,6 +1249,7 @@ dispatch_cmd(conn c)
         if (t) ms_remove(&amp;c-&gt;watch, t); /* may free t if refcount =&gt; 0 */
         t = NULL;
 
+        ignore_ct++;
         reply_line(c, STATE_SENDWORD, &quot;WATCHING %d\r\n&quot;, c-&gt;watch.used);
         break;
     default:</diff>
      <filename>prot.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ca1c4e6160b7f262d2e35074e7032230ff576a89</id>
    </parent>
  </parents>
  <author>
    <name>Keith Rarick</name>
    <email>kr@causes.com</email>
  </author>
  <url>http://github.com/kr/beanstalkd/commit/1c27cefd23be16bb1aa043dcde755c9e9c720f8c</url>
  <id>1c27cefd23be16bb1aa043dcde755c9e9c720f8c</id>
  <committed-date>2008-02-27T10:43:26-08:00</committed-date>
  <authored-date>2008-02-27T10:43:26-08:00</authored-date>
  <message>Add a list-tube-used command and missing stats.</message>
  <tree>60efa1d31ee042d2c097bb888fb18a3e1e65584a</tree>
  <committer>
    <name>Keith Rarick</name>
    <email>kr@causes.com</email>
  </committer>
</commit>
