Fix BufferedPacket race condition (fixes #2983)
authorkwolekr <kwolekr@minetest.net>
Thu, 6 Aug 2015 06:15:21 +0000 (02:15 -0400)
committerkwolekr <kwolekr@minetest.net>
Thu, 6 Aug 2015 06:25:35 +0000 (02:25 -0400)
This was caused by the use the non-threadsafe SharedBuffer in a
threaded context.

src/network/connection.h
src/util/pointer.h

index c48da2c70b50b7a248eb6751e334098e5ba7db3d..f15c3e114995f15354ee25ee46d59095e480c28d 100644 (file)
@@ -172,7 +172,7 @@ struct BufferedPacket
                data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
                resend_count(0)
        {}
-       SharedBuffer<u8> data; // Data of the packet, including headers
+       Buffer<u8> data; // Data of the packet, including headers
        float time; // Seconds from buffering the packet or re-sending
        float totaltime; // Seconds from buffering the packet
        unsigned int absolute_send_time;
index 7922a9b395734bc074e3a911e5f4cd06dde655fb..7f6654787814527f2c38e715a2e8f1f9744e7724 100644 (file)
@@ -178,6 +178,14 @@ private:
        unsigned int m_size;
 };
 
+/************************************************
+ *           !!!  W A R N I N G  !!!            *
+ *           !!!  A C H T U N G  !!!            *
+ *                                              *
+ * This smart pointer class is NOT thread safe. *
+ * ONLY use in a single-threaded context!       *
+ *                                              *
+ ************************************************/
 template <typename T>
 class SharedBuffer
 {