mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00

The architecture of SQLServer is currently such that it sends results over IPC one row at a time. After the rows are exhausted, it sends a completion IPC. However, it does not wait for the client to finish processing a row before sending another row or the completion signal. This can result in clients hanging if the completion comes in while a row is being processed. At least in the case of WebView::Database, the result is that the completion signal is dropped, and the browser then hangs forever waiting for that signal (after it finishes processing the row). This patch makes SQLServer asynchronously wait for the client to tell it that the row has been processed and the next row (or completion) may be sent. We repurpose the `m_ongoing_executions` in SQLStatement for this purpose (this member was oddly being written to, but otherwise unused).
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteString.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/HashMap.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibIPC/ConnectionFromClient.h>
|
|
#include <LibSQL/Type.h>
|
|
#include <SQLServer/SQLClientEndpoint.h>
|
|
#include <SQLServer/SQLServerEndpoint.h>
|
|
|
|
namespace SQLServer {
|
|
|
|
class ConnectionFromClient final
|
|
: public IPC::ConnectionFromClient<SQLClientEndpoint, SQLServerEndpoint> {
|
|
C_OBJECT(ConnectionFromClient);
|
|
|
|
public:
|
|
virtual ~ConnectionFromClient() override = default;
|
|
|
|
virtual void die() override;
|
|
|
|
static RefPtr<ConnectionFromClient> client_connection_for(int client_id);
|
|
|
|
void set_database_path(ByteString);
|
|
Function<void()> on_disconnect;
|
|
|
|
private:
|
|
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
|
|
|
virtual Messages::SQLServer::ConnectResponse connect(ByteString const&) override;
|
|
virtual Messages::SQLServer::PrepareStatementResponse prepare_statement(SQL::ConnectionID, ByteString const&) override;
|
|
virtual Messages::SQLServer::ExecuteStatementResponse execute_statement(SQL::StatementID, Vector<SQL::Value> const& placeholder_values) override;
|
|
virtual void ready_for_next_result(SQL::StatementID, SQL::ExecutionID) override;
|
|
virtual void disconnect(SQL::ConnectionID) override;
|
|
|
|
ByteString m_database_path;
|
|
};
|
|
|
|
}
|