Merge branch 'cassandra-2.1' into cassandra-2.2
diff --git a/CHANGES.txt b/CHANGES.txt
index 0714076..3641afc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,15 +1,16 @@
-2.2.4
- * Fix the regression when using LIMIT with aggregates (CASSANDRA-10487)
 2.2.3
  * Avoid NoClassDefFoundError during DataDescriptor initialization on windows (CASSANDRA-10412)
  * Preserve case of quoted Role & User names (CASSANDRA-10394)
  * cqlsh pg-style-strings broken (CASSANDRA-10484)
  * Make Hadoop CF splits more polite to custom orderered partitioners (CASSANDRA-10400)
+ * Fix the regression when using LIMIT with aggregates (CASSANDRA-10487)
 Merged from 2.1:
  * Fix mmap file segment seeking to EOF (CASSANDRA-10478)
  * Allow LOCAL_JMX to be easily overridden (CASSANDRA-10275)
  * Mark nodes as dead even if they've already left (CASSANDRA-10205)
- * Update internal python driver used by cqlsh (CASSANDRA-10161)
+ * Update internal python driver used by cqlsh (CASSANDRA-10161, CASSANDRA-10507)
+
+
 2.2.2
  * cqlsh prompt includes name of keyspace after failed `use` statement (CASSANDRA-10369)
  * Configurable page size in cqlsh (CASSANDRA-9855)
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index e2691cc..55f7ee9 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -2397,16 +2397,11 @@
                     fetch_size=None, paging_state=None, timestamp=insert_timestamp)
 
                 request_id = conn.get_request_id()
-                binary_message = query_message.to_binary(
-                    stream_id=request_id, protocol_version=DEFAULT_PROTOCOL_VERSION, compression=None)
+                conn.send_msg(query_message, request_id=request_id, cb=partial(callback, current_record))
 
-                # add the message directly to the connection's queue
                 with conn.lock:
                     conn.in_flight += 1
 
-                conn._callbacks[request_id] = partial(callback, current_record)
-                conn.deque.append(binary_message)
-
                 # every 50 records, clear the pending writes queue and read
                 # any responses we have
                 if insert_num % 50 == 0:
@@ -2490,9 +2485,10 @@
             print 'Disabled %s.' % (self.description,)
             return False
 
+
 class SwitchCommandWithValue(SwitchCommand):
     """The same as SwitchCommand except it also accepts a value in place of ON.
-    
+
     This returns a tuple of the form: (SWITCH_VALUE, PASSED_VALUE)
     eg: PAGING 50 returns (True, 50)
         PAGING OFF returns (False, None)
@@ -2503,7 +2499,7 @@
     def __init__(self, command, desc, value_type=int):
         SwitchCommand.__init__(self, command, desc)
         self.value_type = value_type
-        
+
     def execute(self, state, parsed, printerr):
         binary_switch_value = SwitchCommand.execute(self, state, parsed, printerr)
         switch = parsed.get_binding('switch')
@@ -2514,6 +2510,7 @@
             value = None
         return (binary_switch_value, value)
 
+
 def option_with_default(cparser_getter, section, option, default=None):
     try:
         return cparser_getter(section, option)