delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/03/27/10:54:34

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5472D385E024
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1585320823;
bh=2QjgmKIK2pVv63qJngXIxEd36wUKE5izMqBiOXKiA9Y=;
h=To:References:In-Reply-To:Subject:Date:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=KxwXaHwHl45yX1icKHqhyOc+/pSfCpKM23BfQcO9dHsC9l+GHv5Tvmr8yeKhePtbQ
9BHTZbJePcsj7j8WCiBwB9v/wGku/vmi1QZaR9IuodSAcg4vRanNb1CNBe6Uq3fXwY
D0Azvf0nRRhC6aONb2IikApjkVJ0yYncqF08iGdw=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 876F4385E006
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date
:message-id:mime-version:thread-index:content-language;
bh=A1xKxVrmbo4Jonss95j3/bchuYMNecqe1JIXdLWGNYU=;
b=T/4Y2BkxB5chHsTaPBjiQ0JAc2dnHoxKiqNPuyVWmZfeMr8VoCvR7x6ctY6nfVP/Tg
LIgrypfRh1V8GfaAj6o5qpzRnaG+jgMDqEou1j7j9u1XMiO/3Kd3N7WYY79/ubVC6Jgg
vTG3Dxj9xjJg4zOL1WRe2srntBc1fD1Lftugn5+JvBcfqyySKcX8zHlTjal7wxc9Ogrl
uZQDmnJlaDUwKo1nmne9199HXENpHcUEWzNiqvHblnw4nhFXEIXowV5S1yQ01sUEVVfa
2lI6BWzw+Ax3UNoFRyxgqc4zt5WShfnRykme6xgUYuwggUi1vmKKQ85QO7YoSsF0p70Z
zOmQ==
X-Gm-Message-State: ANhLgQ1fRu0nbe9tf3NHAj/APFHeEu6I8OdI1pTtFYHlh/MkrWqX0rKV
30TAY/34jAiZHL96q3cq9fCoUyMj
X-Google-Smtp-Source: ADFU+vtbcZfDGY2Kg0HaP8MKlC5NKTu6I7ew4c0DLQiGcWiunqgp/NXxepX8JYa58TtwC7/ksDLQwQ==
X-Received: by 2002:a05:651c:390:: with SMTP id
e16mr8318351ljp.142.1585320817908;
Fri, 27 Mar 2020 07:53:37 -0700 (PDT)
To: "'Ken Brown'" <kbrown AT cornell DOT edu>
References: <1b1401d60296$2769e690$763db3b0$@gmail.com>
<716e2076-f607-454e-2723-937c3959e2a3 AT cornell DOT edu>
<18be01d602ab$0bbfca30$233f5e90$@gmail.com>
<35b43b59-6410-f21f-710c-385e39cbae0b AT cornell DOT edu>
<005201d603ba$2bc8ab20$835a0160$@gmail.com>
<472d1df6-531a-ebd7-4ffa-583a06e270ff AT cornell DOT edu>
<ce4a4877-df77-3400-e8ac-16655b313757 AT cornell DOT edu>
<b311d907-7376-5bc6-3216-7d2b96728dbc AT cornell DOT edu>
In-Reply-To: <b311d907-7376-5bc6-3216-7d2b96728dbc@cornell.edu>
Subject: Sv: Sv: Sv: Named pipes and multiple writers
Date: Fri, 27 Mar 2020 15:53:36 +0100
Message-ID: <00b901d60447$7ecb4c50$7c61e4f0$@gmail.com>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQJE9fQg8TMZuJRGwTEKbo0ZGNgDeQHtMggPA01jw/MCH/KUAAKPevBvAf/qW+kC4eksHQHeBGSzpvlSQYA=
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <http://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Kristian Ivarsson via Cygwin <cygwin AT cygwin DOT com>
Reply-To: sten DOT kristian DOT ivarsson AT gmail DOT com
Cc: "'cygwin'" <cygwin AT cygwin DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

This is a multipart message in MIME format.

------=_NextPart_000_00BA_01D6044F.E08FDB60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

>On 3/26/2020 7:19 PM, Ken Brown via Cygwin wrote:
>> On 3/26/2020 6:39 PM, Ken Brown via Cygwin wrote:
>>> On 3/26/2020 6:01 PM, sten DOT kristian DOT ivarsson AT gmail DOT com wrote:
>>>> The ENIXIO occurs when parallel child-processes simultaneously =
using=20
>>>> O_NONBLOCK opening the descriptor.
>>>
>>> This is consistent with my guess that the error is generated by=20
>>> fhandler_fifo::wait.=A0 I have a feeling that read_ready should have =

>>> been created as a manual-reset event, and that more care is needed =
to=20
>>> make sure it's set when it should be.
>>>
>>>> I could provide a code-snippet
>>>> to reproduce it if wanted ?
>>>
>>> Yes, please!
>>=20
>> That might not be necessary.=A0 If you're able to build the git repo=20
>> master branch, please try the attached patch.

>Here's a better patch.


I finally succeeded to build latest master (make is not my favourite =
tool)
and added the patch, but still no success in my little test-program (see
attachment) when creating a write-file-descriptor with O_NONBLOCK

=20
>Ken

------=_NextPart_000_00BA_01D6044F.E08FDB60
Content-Type: text/plain;
	name="pipe.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="pipe.cpp"

#include <cstring>

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <iostream>
#include <string>

namespace
{
   auto error(const int error)
   {
      std::cerr << getpid() << "\terror:\t" << error << '\t' << =
std::strerror(error) << std::endl;
      return error;
   }
}

int main()
{
   const auto name{"/tmp/my_name"};

   const auto result =3D mkfifo(name, 0666);

   if(result) return error(errno);

   constexpr auto writers{5};
   constexpr auto messages{4};

   for(auto idx =3D 0; idx < writers; ++idx)
   {
      const auto pid =3D fork();

      if(pid < 0) return error(errno);

      if(pid =3D=3D 0)
      {
         std::cout << "child " << getpid() << std::endl;
         for(auto idx =3D 0; idx < messages; ++idx)
         {
            const auto wfd =3D open(name, O_WRONLY | O_NONBLOCK);
            if(wfd < 0) return error(errno);
            const auto msg{std::to_string(getpid())};
            if(write(wfd, msg.data(), msg.size() + 1) < 0) error(errno);
            close(wfd);
         }
         return 0;
      }
   }

   {
      std::cout << "parent" << std::endl;

      const auto rfd =3D open(name, O_RDONLY);
      const auto wfd =3D open(name, O_WRONLY);
      if(rfd < 0) return error(errno);
      for(auto idx =3D 0; idx < writers * messages; ++idx)
      {
         std::string buffer;
         buffer.resize(80);
         if(read(rfd, &buffer[0], buffer.size()) < 0) error(errno);
         std::cout << buffer << std::endl;
      }
      close(wfd);
      close(rfd);
   }

   if(unlink(name) < 0) return error(errno);

   return 0;
}
------=_NextPart_000_00BA_01D6044F.E08FDB60
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

------=_NextPart_000_00BA_01D6044F.E08FDB60--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019