THRIFT-388. Create a "ONEWAY" message type that is an alias for "CALL"

Pave the way for a new message type for oneway function calls.
For now, just define the constant in all languages and make
server implementations treat it the same way as a normal call.
Only C++ and Erlang currently check the message type (on the
server side).

There is a little bit of redundancy in the Erlang code, but
the alternative is a bit gross, and this split-up will be
necessary eventually when we start handling one-way calls
differently.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761389 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 9d57269..00c813e 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -1909,7 +1909,7 @@
     endl <<
     indent() << "iprot->readMessageBegin(fname, mtype, seqid);" << endl <<
     endl <<
-    indent() << "if (mtype != apache::thrift::protocol::T_CALL) {" << endl <<
+    indent() << "if (mtype != apache::thrift::protocol::T_CALL && mtype != apache::thrift::protocol::T_ONEWAY) {" << endl <<
     indent() << "  iprot->skip(apache::thrift::protocol::T_STRUCT);" << endl <<
     indent() << "  iprot->readMessageEnd();" << endl <<
     indent() << "  iprot->getTransport()->readEnd();" << endl <<
diff --git a/lib/cocoa/src/protocol/TProtocol.h b/lib/cocoa/src/protocol/TProtocol.h
index 126f5df..cc8cdb4 100644
--- a/lib/cocoa/src/protocol/TProtocol.h
+++ b/lib/cocoa/src/protocol/TProtocol.h
@@ -25,7 +25,8 @@
 enum {
   TMessageType_CALL = 1,
   TMessageType_REPLY = 2,
-  TMessageType_EXCEPTION = 3
+  TMessageType_EXCEPTION = 3,
+  TMessageType_ONEWAY = 4
 };
 
 enum {
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 37d0801..0c513d1 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -97,7 +97,8 @@
 enum TMessageType {
   T_CALL       = 1,
   T_REPLY      = 2,
-  T_EXCEPTION  = 3
+  T_EXCEPTION  = 3,
+  T_ONEWAY     = 4
 };
 
 /**
diff --git a/lib/csharp/src/Protocol/TMessageType.cs b/lib/csharp/src/Protocol/TMessageType.cs
index 42a6a20..ab07cf6 100644
--- a/lib/csharp/src/Protocol/TMessageType.cs
+++ b/lib/csharp/src/Protocol/TMessageType.cs
@@ -25,6 +25,7 @@
 	{
 		Call = 1,
 		Reply = 2,
-		Exception = 3
+		Exception = 3,
+		Oneway = 4
 	}
 }
diff --git a/lib/erl/include/thrift_constants.hrl b/lib/erl/include/thrift_constants.hrl
index 40c0c16..36eb49b 100644
--- a/lib/erl/include/thrift_constants.hrl
+++ b/lib/erl/include/thrift_constants.hrl
@@ -36,6 +36,7 @@
 -define(tMessageType_CALL, 1).
 -define(tMessageType_REPLY, 2).
 -define(tMessageType_EXCEPTION, 3).
+-define(tMessageType_ONEWAY, 4).
 
 % TApplicationException
 -define(TApplicationException_Structure,
diff --git a/lib/erl/src/thrift_processor.erl b/lib/erl/src/thrift_processor.erl
index 1adea67..e26fb33 100644
--- a/lib/erl/src/thrift_processor.erl
+++ b/lib/erl/src/thrift_processor.erl
@@ -40,6 +40,10 @@
                                 type = ?tMessageType_CALL} ->
             ok = handle_function(State, list_to_atom(Function)),
             loop(State);
+        #protocol_message_begin{name = Function,
+                                type = ?tMessageType_ONEWAY} ->
+            ok = handle_function(State, list_to_atom(Function)),
+            loop(State);
         {error, timeout} ->
             thrift_protocol:close_transport(OProto),
             ok;
diff --git a/lib/hs/src/Thrift.hs b/lib/hs/src/Thrift.hs
index b3ce8a4..293edf1 100644
--- a/lib/hs/src/Thrift.hs
+++ b/lib/hs/src/Thrift.hs
@@ -118,6 +118,7 @@
   data Message_type = M_CALL
                     | M_REPLY
                     | M_EXCEPTION
+                    | M_ONEWAY
                     | M_UNKNOWN
                       deriving Eq
   instance Enum Message_type where
@@ -126,12 +127,14 @@
                      M_CALL -> 1
                      M_REPLY -> 2
                      M_EXCEPTION -> 3
+                     M_ONEWAY -> 4
                      M_UNKNOWN -> -1
 
       toEnum t = case t of
                    1 -> M_CALL
                    2 -> M_REPLY
                    3 -> M_EXCEPTION
+                   4 -> M_ONEWAY
                    _ -> M_UNKNOWN
 
 
diff --git a/lib/java/src/org/apache/thrift/protocol/TMessageType.java b/lib/java/src/org/apache/thrift/protocol/TMessageType.java
index 714ea70..aa3f931 100644
--- a/lib/java/src/org/apache/thrift/protocol/TMessageType.java
+++ b/lib/java/src/org/apache/thrift/protocol/TMessageType.java
@@ -27,4 +27,5 @@
   public static final byte CALL  = 1;
   public static final byte REPLY = 2;
   public static final byte EXCEPTION = 3;
+  public static final byte ONEWAY = 4;
 }
diff --git a/lib/ocaml/src/Thrift.ml b/lib/ocaml/src/Thrift.ml
index 0d16470..8dc9afa 100644
--- a/lib/ocaml/src/Thrift.ml
+++ b/lib/ocaml/src/Thrift.ml
@@ -141,16 +141,19 @@
     | CALL
     | REPLY
     | EXCEPTION
+    | ONEWAY
 
   let message_type_to_i = function
     | CALL -> 1
     | REPLY -> 2
     | EXCEPTION -> 3
+    | ONEWAY -> 4
 
   let message_type_of_i = function
     | 1 -> CALL
     | 2 -> REPLY
     | 3 -> EXCEPTION
+    | 4 -> ONEWAY
     | _ -> raise Thrift_error
 
   class virtual t (trans: Transport.t) =
diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm
index 2560df7..fe0f8e7 100644
--- a/lib/perl/lib/Thrift.pm
+++ b/lib/perl/lib/Thrift.pm
@@ -53,6 +53,7 @@
 use constant CALL      => 1;
 use constant REPLY     => 2;
 use constant EXCEPTION => 3;
+use constant ONEWAY    => 4;
 1;
 
 package Thrift::TException;
diff --git a/lib/php/src/Thrift.php b/lib/php/src/Thrift.php
index dd1e0d7..ef6ab8a 100644
--- a/lib/php/src/Thrift.php
+++ b/lib/php/src/Thrift.php
@@ -51,6 +51,7 @@
   const CALL  = 1;
   const REPLY = 2;
   const EXCEPTION = 3;
+  const ONEWAY = 4;
 }
 
 /**
diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py
index 601b41c..21d7aa4 100644
--- a/lib/py/src/Thrift.py
+++ b/lib/py/src/Thrift.py
@@ -40,6 +40,7 @@
   CALL  = 1
   REPLY = 2
   EXCEPTION = 3
+  ONEWAY = 4
 
 class TProcessor:
 
diff --git a/lib/rb/lib/thrift/types.rb b/lib/rb/lib/thrift/types.rb
index 6d70eb5..20e4ca2 100644
--- a/lib/rb/lib/thrift/types.rb
+++ b/lib/rb/lib/thrift/types.rb
@@ -94,6 +94,7 @@
     CALL = 1
     REPLY = 2
     EXCEPTION = 3
+    ONEWAY = 4
   end
 end