Skip to content

Commit

Permalink
Drop poll() support for windows streams
Browse files Browse the repository at this point in the history
  • Loading branch information
techee committed Dec 19, 2024
1 parent 3494370 commit ff644a6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
36 changes: 0 additions & 36 deletions lsp/src/spawn/lspunixinputstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,47 +296,13 @@ lsp_unix_input_stream_read (GInputStream *stream,
{
LspUnixInputStream *unix_stream;
gssize res = -1;
GPollFD poll_fds[2];
int nfds;
int poll_ret;

unix_stream = LSP_UNIX_INPUT_STREAM (stream);

poll_fds[0].fd = unix_stream->priv->fd;
poll_fds[0].events = G_IO_IN;
if (unix_stream->priv->can_poll &&
g_cancellable_make_pollfd (cancellable, &poll_fds[1]))
nfds = 2;
else
nfds = 1;

while (1)
{
int errsv;

poll_fds[0].revents = poll_fds[1].revents = 0;
do
{
poll_ret = g_poll (poll_fds, nfds, -1);
errsv = errno;
}
while (poll_ret == -1 && errsv == EINTR);

if (poll_ret == -1)
{
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errsv),
"Error reading from file descriptor: %s",
g_strerror (errsv));
break;
}

if (g_cancellable_set_error_if_cancelled (cancellable, error))
break;

if (!poll_fds[0].revents)
continue;

res = read (unix_stream->priv->fd, buffer, count);
if (res == -1)
{
Expand All @@ -354,8 +320,6 @@ lsp_unix_input_stream_read (GInputStream *stream,
break;
}

if (nfds == 2)
g_cancellable_release_fd (cancellable);
return res;
}

Expand Down
36 changes: 0 additions & 36 deletions lsp/src/spawn/lspunixoutputstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,47 +282,13 @@ lsp_unix_output_stream_write (GOutputStream *stream,
{
LspUnixOutputStream *unix_stream;
gssize res = -1;
GPollFD poll_fds[2];
int nfds = 0;
int poll_ret;

unix_stream = LSP_UNIX_OUTPUT_STREAM (stream);

poll_fds[0].fd = unix_stream->priv->fd;
poll_fds[0].events = G_IO_OUT;
nfds++;

if (unix_stream->priv->can_poll &&
g_cancellable_make_pollfd (cancellable, &poll_fds[1]))
nfds++;

while (1)
{
int errsv;

poll_fds[0].revents = poll_fds[1].revents = 0;
do
{
poll_ret = g_poll (poll_fds, nfds, -1);
errsv = errno;
}
while (poll_ret == -1 && errsv == EINTR);

if (poll_ret == -1)
{
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errsv),
"Error writing to file descriptor: %s",
g_strerror (errsv));
break;
}

if (g_cancellable_set_error_if_cancelled (cancellable, error))
break;

if (!poll_fds[0].revents)
continue;

res = write (unix_stream->priv->fd, buffer, count);
errsv = errno;
if (res == -1)
Expand All @@ -339,8 +305,6 @@ lsp_unix_output_stream_write (GOutputStream *stream,
break;
}

if (nfds == 2)
g_cancellable_release_fd (cancellable);
return res;
}

Expand Down

0 comments on commit ff644a6

Please sign in to comment.