Add more checks and warnings for cork buffer misuse
This commit is contained in:
+3
-1
@@ -25,6 +25,7 @@
|
||||
* to signal error with -1 (which is how the entire UNIX syscalling is built). */
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "libusockets.h"
|
||||
|
||||
@@ -82,7 +83,8 @@ protected:
|
||||
void cork() {
|
||||
/* Extra check for invalid corking of others */
|
||||
if (getLoopData()->corkOffset && getLoopData()->corkedSocket != this) {
|
||||
std::abort();
|
||||
std::cerr << "Error: Cork buffer must not be acquired without checking canCork!" << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
/* What if another socket is corked? */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "LoopData.h"
|
||||
#include <libusockets.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace uWS {
|
||||
struct Loop {
|
||||
@@ -56,6 +57,12 @@ private:
|
||||
for (auto &p : loopData->postHandlers) {
|
||||
p.second((Loop *) loop);
|
||||
}
|
||||
|
||||
/* After every event loop iteration, we must not hold the cork buffer */
|
||||
if (loopData->corkedSocket) {
|
||||
std::cerr << "Error: Cork buffer must not be held across event loop iterations!" << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
Loop() = delete;
|
||||
|
||||
Reference in New Issue
Block a user