Merge remote-tracking branch 'krobelus/fix-crash-connecting-monitor'
This commit is contained in:
commit
3d989af2de
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,7 +5,9 @@
|
|||
.*.kak.*
|
||||
src/kak
|
||||
src/kak.debug
|
||||
src/kak.debug.san_*
|
||||
src/kak.opt
|
||||
src/kak.opt.san_*
|
||||
src/.version*
|
||||
src/.*.json
|
||||
doc/kak.1.gz
|
||||
|
|
10
src/file.cc
10
src/file.cc
|
@ -252,13 +252,14 @@ bool regular_file_exists(StringView filename)
|
|||
(st.st_mode & S_IFMT) == S_IFREG;
|
||||
}
|
||||
|
||||
template<bool atomic>
|
||||
void write(int fd, StringView data)
|
||||
{
|
||||
const char* ptr = data.data();
|
||||
ssize_t count = (int)data.length();
|
||||
|
||||
int flags = fcntl(fd, F_GETFL, 0);
|
||||
if (EventManager::has_instance())
|
||||
if (not atomic and EventManager::has_instance())
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
auto restore_flags = on_scope_end([&] { fcntl(fd, F_SETFL, flags); });
|
||||
|
||||
|
@ -269,12 +270,15 @@ void write(int fd, StringView data)
|
|||
ptr += written;
|
||||
count -= written;
|
||||
}
|
||||
else if (errno == EAGAIN and EventManager::has_instance())
|
||||
else if (errno == EAGAIN and not atomic and EventManager::has_instance())
|
||||
EventManager::instance().handle_next_events(EventMode::Urgent, nullptr, false);
|
||||
else
|
||||
throw file_access_error(format("fd: {}", fd), strerror(errno));
|
||||
}
|
||||
}
|
||||
template void write<true>(int fd, StringView data);
|
||||
template void write<false>(int fd, StringView data);
|
||||
|
||||
|
||||
void write_to_file(StringView filename, StringView data)
|
||||
{
|
||||
|
@ -295,7 +299,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd)
|
|||
eoldata = "\n";
|
||||
|
||||
|
||||
BufferedWriter writer{fd};
|
||||
BufferedWriter<false> writer{fd};
|
||||
if (buffer.options()["BOM"].get<ByteOrderMark>() == ByteOrderMark::Utf8)
|
||||
writer.write("\xEF\xBB\xBF");
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ bool fd_readable(int fd);
|
|||
bool fd_writable(int fd);
|
||||
String read_fd(int fd, bool text = false);
|
||||
String read_file(StringView filename, bool text = false);
|
||||
template<bool force_blocking = false>
|
||||
void write(int fd, StringView data);
|
||||
void write_to_file(StringView filename, StringView data);
|
||||
|
||||
|
@ -121,7 +122,7 @@ CandidateList complete_filename(StringView prefix, const Regex& ignore_regex,
|
|||
|
||||
CandidateList complete_command(StringView prefix, ByteCount cursor_pos = -1);
|
||||
|
||||
template<int buffer_size = 4096>
|
||||
template<bool atomic, int buffer_size = 4096>
|
||||
struct BufferedWriter
|
||||
{
|
||||
BufferedWriter(int fd)
|
||||
|
@ -149,7 +150,7 @@ struct BufferedWriter
|
|||
|
||||
void flush()
|
||||
{
|
||||
Kakoune::write(m_fd, {m_buffer, m_pos});
|
||||
Kakoune::write<atomic>(m_fd, {m_buffer, m_pos});
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ void TerminalUI::Window::draw(DisplayCoord pos,
|
|||
lines[(int)pos.line].append({}, size.column - pos.column, default_face);
|
||||
}
|
||||
|
||||
struct Writer : BufferedWriter<>
|
||||
struct Writer : BufferedWriter<true>
|
||||
{
|
||||
using Writer::BufferedWriter::BufferedWriter;
|
||||
~Writer() noexcept(false) = default;
|
||||
|
|
|
@ -10,3 +10,6 @@ ui_in '{ "jsonrpc": "2.0", "method": "mouse_release", "params": [ "left", 0, 4 ]
|
|||
sleep .1
|
||||
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "c<esc>" ] }'
|
||||
sleep .1
|
||||
if [ -n "$CI" ]; then
|
||||
sleep 1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user