Fix deadlock

This commit is contained in:
2026-02-05 13:03:41 +00:00
parent a62d4a18a8
commit dd474cc38d
2 changed files with 19 additions and 19 deletions

13
TODO.md
View File

@@ -9,11 +9,11 @@ Copyright 2025 Syed Daanish
128M -> 412.0M (expected worst case 2.3G)
```
* Next few super long boring things to do
* redo lsp threads such that no mutex needed for any rope stuff (necessary rn)
- Also make the classes own the methods in lsp
- This will mean that parsers/renderers and keystrokes will not need to be individually locked
- And so it will be much faster
## Next few super long boring things to do::
* redo lsp threads such that no mutex needed for any rope stuff (done)
- Also make the classes own the methods in lsp (done)
- This will mean that parsers/renderers and keystrokes will not need to be individually locked (done)
- And so it will be much faster (done)
- At which point the main thread can also be blocked on user input or lsp responses and still be fast
* Add a superclass for editor called Window (which can be popup or tiled) (done)
* Add a recursive tiling class for windows (done)
@@ -23,6 +23,9 @@ Copyright 2025 Syed Daanish
- Seperate system functions into a class that branches to support local / ssh / server modes.
- Even lsp shouldnt be directly controlled because it can branch on local and server modes
- check wolfSSH stuff for remote editing
- Thick and thin mode
- thin mode only shares screen diffing over the network - uses server settings / themes
- thick only shared fileio and lsp data with local used for all else - uses local settings / themes
- Redo hooks as a engine of its own.
- And factorize renderer into its own class (and make it just return an array of the render without knowing teh x,y)
- which is just managed by the renderer

View File

@@ -95,7 +95,6 @@ struct LSPInstance {
return;
}
json response = *read_lsp_message();
log("Lsp response: %s", response.dump().c_str());
if (response.contains("result") &&
response["result"].contains("capabilities")) {
auto &caps = response["result"]["capabilities"];
@@ -191,11 +190,11 @@ struct LSPInstance {
json shutdown = {{"id", ++last_id}, {"method", "shutdown"}};
send_raw(shutdown);
pollfd pfd{stdout_fd, POLLIN, 0};
poll(&pfd, 1, LSP_TIMEOUT);
poll(&pfd, 1, 500);
json exit_msg = {{"method", "exit"}};
send_raw(exit_msg);
int waited = 0;
while (waited < LSP_TIMEOUT) {
while (waited < 100) {
int status;
pid_t res = waitpid(pid, &status, WNOHANG);
if (res == pid)
@@ -252,22 +251,20 @@ struct LSPInstance {
return true;
}
void add(Editor *ed) {
std::unique_lock lock(lsp::lsp_mutex);
editors.push_back(ed);
lock.unlock();
ed->lsp.store(this);
char *buf = read(ed->root, 0, ed->root->char_count);
std::string text(buf);
free(buf);
auto message = std::make_unique<LSPMessage>();
message->message = {{"method", "textDocument/didOpen"},
json message = {{"jsonrpc", "2.0"},
{"method", "textDocument/didOpen"},
{"params",
{{"textDocument",
{{"uri", ed->uri},
{"languageId", ed->lang.name},
{"version", 1},
{"text", text}}}}}};
send(std::move(message));
send_raw(message);
}
void remove(Editor *ed) {
std::unique_lock lock(lsp::lsp_mutex);