Merge v301 (#3395)

* [3.0.1] fix websocket crash (#3344)
* add lock
* use std::recursive_mutex (#3374)
This commit is contained in:
minggo
2021-04-15 09:45:59 +08:00
committed by GitHub
parent e59d7b4c98
commit 46a455aa84
3 changed files with 254 additions and 253 deletions
+2
View File
@@ -13,6 +13,7 @@
# -readability-implicit-bool-conversion: We omit explicit bool conversion for brevity
# -readability-implicit-bool-cast: We omit explicit bool conversion for brevity
# -readability-magic-numbers: There will be lots of constants
# -bugprone-branch-clone: two branches may only print debug message, then will be treat as the same logic.
Checks: >
-*,
@@ -35,6 +36,7 @@ Checks: >
-readability-implicit-bool-conversion,
-readability-implicit-bool-cast,
-readability-magic-numbers,
-bugprone-branch-clone,
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
File diff suppressed because it is too large Load Diff
+8 -14
View File
@@ -53,8 +53,6 @@ namespace cc {
namespace network {
class WebSocketFrame;
/**
* WebSocket is wrapper of the libwebsockets-protocol, let the develop could call the websocket easily.
* Please note that all public methods of WebSocket have to be invoked on Cocos Thread.
@@ -81,23 +79,19 @@ private:
* @js NA
* @lua NA
*/
virtual ~WebSocket();
~WebSocket() override;
public:
/**
* Data structure for message
*/
struct Data {
Data() : bytes(nullptr),
len(0),
issued(0),
isBinary(false),
ext(nullptr) {}
char *bytes;
ssize_t len, issued;
bool isBinary;
void *ext;
ssize_t getRemain() { return std::max((ssize_t)0, len - issued); }
Data() = default;
char *bytes{nullptr};
ssize_t len{0}, issued{0};
bool isBinary{false};
void *ext{nullptr};
ssize_t getRemain() const { return std::max(static_cast<ssize_t>(0), len - issued); }
};
/**
@@ -128,7 +122,7 @@ public:
class Delegate {
public:
/** Destructor of Delegate. */
virtual ~Delegate() {}
virtual ~Delegate() = default;
/**
* This function to be called after the client connection complete a handshake with the remote server.
* This means that the WebSocket connection is ready to send and receive data.