From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 4A6B2385BF9E for ; Tue, 23 Mar 2021 15:37:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4A6B2385BF9E Received: by mail-lf1-x12b.google.com with SMTP id g8so20167917lfv.12 for ; Tue, 23 Mar 2021 08:37:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-language:thread-index; bh=GaYAIHBrDA6AaoxnREepfsIBCHTODFJ5RhjT5OC6P6I=; b=EzDqS/+9FZ5tBc7RbXgyHxsvCBl6A9WdQ2rBB2u2eamVXyg/0CGkhWLAyORRomHt+j 6DE5GaX9hRoYKORiyw5fpWfRm8qAuaipzxYaLvzlaTcQiuf+//TM7mAxNfs/yBg68NZP nI9vtfIjnH8i8h9YRnoZVk4NfWlTLRjHCVYwaO4xc//h2qmjarEuyryou8qOEZvV8rXd paxfWjzWAQOvkW78qX3WKgYiXLvN5Db6Yiwb9p39gmMpOLGtDc66/f1UxAhqCA7tNrQE 9wrB7rZGTsbep0ZBY7ehrRR4/Z603l/XIoLFqg3ZAHsNV+RIoTgzcFjrSZCLJZFxYVSQ oV0Q== X-Gm-Message-State: AOAM532e6KRiR3b6vCkhQinPP/QRRV1Bz/QZBYtB4jYumzemeQvWlCoP R6iezRw9eCn/gRAEH2S7Z3KO6oZ8+zkZvg== X-Google-Smtp-Source: ABdhPJyrABSjUE512Az6uhT8qC66uCnbYZag6nFTzZzvgb93BxfAMdNM68NK1aM5UwE6y1CYsyJc4g== X-Received: by 2002:a19:cd1:: with SMTP id 200mr2973441lfm.480.1616513873036; Tue, 23 Mar 2021 08:37:53 -0700 (PDT) Received: from zingo (87-249-172-112.ljusnet.se. [87.249.172.112]) by smtp.gmail.com with ESMTPSA id h9sm2379909ljh.58.2021.03.23.08.37.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Mar 2021 08:37:52 -0700 (PDT) From: To: Subject: AF_UNIX/SOCK_DGRAM is dropping messages Date: Tue, 23 Mar 2021 16:37:52 +0100 Message-ID: <04cc01d71ffa$7d1e6cf0$775b46d0$@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_04CD_01D72002.DEE34A20" X-Mailer: Microsoft Outlook 16.0 Content-Language: en-se Thread-Index: Adcf+Ru9MZOaiVQtQ0esx7k4nMjxfA== X-Spam-Status: No, score=-1.7 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2021 15:38:04 -0000 This is a multipart message in MIME format. ------=_NextPart_000_04CD_01D72002.DEE34A20 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi all Using AF_UNIX/SOCK_DGRAM with current version (3.2.0) seems to drop = messages or at least they are not received in the same order they are = sent Attached C:ish (with C++ threads though) sample program that essentially = creates a "client" that writes as much as possible and a "server" that = consumes as much as possible It seems like some buffer is filled and then messages are dropped (or at = least it appears so) (if someone is about to test this, the "sleep" = might need to be adjusted in order to make this happen) Hopefully it's just a flaw in our application (and sample), but as far = as we can see, this should work Does anyone, perhaps named Ken, have any insightful thoughts about this = ? Best regards, Kristian ------=_NextPart_000_04CD_01D72002.DEE34A20 Content-Type: text/plain; name="af_unix.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="af_unix.cpp" #include #include #include #include #include #include #include #include // $ g++ --std=3Dgnu++17 af_unix.cpp const char* const path =3D "address"; const int count =3D 1000; const int size =3D BUFSIZ * 2; int client() { const int fd =3D socket( AF_UNIX, SOCK_DGRAM, 0); if( fd =3D=3D -1) { perror( "socket error"); return -1; } struct sockaddr_un address{}; strcpy( address.sun_path, path); address.sun_family =3D AF_UNIX; char buffer[size] =3D {}; for( int idx =3D 0; idx < count; ++idx) { memcpy( buffer, &idx, sizeof idx); const ssize_t result =3D sendto( fd, buffer, size, 0, (struct = sockaddr*)&address, sizeof address); if( result =3D=3D -1) { perror( "sendto error"); return -1; } } close( fd); return 0; } int server() { const int fd =3D socket( AF_UNIX, SOCK_DGRAM, 0); if( fd =3D=3D -1) { perror( "socket error"); return -1; } struct sockaddr_un address{}; strcpy( address.sun_path, path); address.sun_family =3D AF_UNIX; const int result =3D bind( fd, (struct sockaddr*)&address, sizeof = address); if( result =3D=3D -1) { perror( "bind error"); return -1; } return fd; } int main( int argc, char* argv[]) { const int fd =3D server( ); if( fd !=3D -1) { fprintf( stdout, "%d\tnumber of packages\n", count); fprintf( stdout, "%d\tbytes per package\n", size); std::thread c{ [&](){client( );}}; std::this_thread::sleep_for( std::chrono::microseconds( 500)); =20 char buffer[size] =3D {}; for( int idx =3D 0; idx < count; ++idx) { const ssize_t result =3D recv( fd, buffer, size, 0); if( result =3D=3D -1) { perror("recv error"); c.join(); unlink( path); return -1; } int index =3D 0; memcpy( &index, buffer, sizeof idx); if( index !=3D idx) { fprintf( stderr, "expected %d but got %d\n", idx, = index); c.join(); unlink( path); return -1; } } c.join(); close( fd); unlink( path); } return 0; } ------=_NextPart_000_04CD_01D72002.DEE34A20--