glib2.0 2.64.6-1 (TEST)

Jon Turney jon.turney@dronecode.org.uk
Fri Jul 28 15:17:03 GMT 2023


On 26/07/2023 15:33, Corinna Vinschen wrote:
> On Jul  3 15:49, Jon Turney wrote:
>> On 02/07/2023 15:30, Jon Turney wrote:
>>>
>>> There are many test-suite failures, however, as far as I can tell, they
>>> are not regressions, so this should work as well as it ever did.
>>
>> At least some of these test failures are due to bugs or shortcomings in the
>> Cygwin DLL. In an ideal world, I'd have the time and motivation to
>> investigate them all, but here's a brief summary of the few I looked into
>> ...
> 
>> stream_rw-all: writes to a pipe until it's full, then ends up blocking when
>> poll() still indicates it's writeable?
> 
> Pipes never worked 100% POSIX-like, unfortunately, but the hang
> was supposed to be fixed by introducingh the semaphore select_sem.
> 
> Do you have an STC?  Takashi, can you take a look?

So, I messed up: it's a socketpair, not a pipe.  And I typoed the test 
name, it's actually stream-rw_all

If I'm remembering correctly, it ends up getting stuck at:

https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/tests/stream-rw_all.c#L179

I think this boils down to just:

- create a socketpair
- while polling if socket is writeable, write 100 zeroes to socket

This should stop when socket is not writeable, but actually just seems 
to block in the write.

Attached is an attempt at that, stripping out the glib stuff, which does 
indeed gets stuck. But maybe I messed up, the expectations of the test 
aren't good...
-------------- next part --------------
#include <assert.h>
#include <poll.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>

int main()
{
  char wbuf[100] = { 0, };
  int out;

  {
    int sv[2];
    int s;

    s = socketpair (AF_UNIX, SOCK_STREAM, 0, sv);
    assert (s == 0);

    out = sv[0];
  }

  size_t in_flight = 0;
  while (1)
    {
      struct pollfd fds[1];
      fds[0].fd = out;
      fds[0].events = POLLOUT;

      int r = poll(fds, 1, 0);
      assert(r >= 0);

      // fd is not ready to write
      if (!(fds[0].revents & POLLOUT))
        break;

      // otherwise, fd is ready to write, implies some data may be written without blocking
      ssize_t s = write (out, wbuf, sizeof wbuf);
      assert (s > 0);
      in_flight += s;
      printf("%zd written, total in_flight %zd\n", s, in_flight);
    }
}


More information about the Cygwin-developers mailing list