add 'discardAll' parameter to socket:close(...)
This commit is contained in:
parent
20bd7666cd
commit
d2bbd82dbe
@ -73,7 +73,7 @@ static int l_connect(lua::State* L) {
|
||||
static int l_close(lua::State* L) {
|
||||
u64id_t id = lua::tointeger(L, 1);
|
||||
if (auto connection = engine->getNetwork().getConnection(id)) {
|
||||
connection->close();
|
||||
connection->close(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -400,10 +400,15 @@ public:
|
||||
return readBatch.size();
|
||||
}
|
||||
|
||||
void close() override {
|
||||
if (state != ConnectionState::CLOSED) {
|
||||
shutdown(descriptor, 2);
|
||||
closesocket(descriptor);
|
||||
void close(bool discardAll=false) override {
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
readBatch.clear();
|
||||
|
||||
if (state != ConnectionState::CLOSED) {
|
||||
shutdown(descriptor, 2);
|
||||
closesocket(descriptor);
|
||||
}
|
||||
}
|
||||
if (thread) {
|
||||
thread->join();
|
||||
|
||||
@ -49,7 +49,7 @@ namespace network {
|
||||
virtual void connect(runnable callback) = 0;
|
||||
virtual int recv(char* buffer, size_t length) = 0;
|
||||
virtual int send(const char* buffer, size_t length) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void close(bool discardAll=false) = 0;
|
||||
virtual int available() = 0;
|
||||
|
||||
virtual size_t pullUpload() = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user