[Issue 1491] New: if working with timed-out socket, SIGPIPE will kill program

Downs default_357-line at yahoo.de
Wed Sep 12 18:12:58 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ingo Oeser wrote:
> Downs wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Alright, here's a revised version of the patch.
> 
> That one was much better. Could you please fix the sendTo()
> method calling .sendto(), too?
> 
> Many thanks!
> 
> 
> Best Regards
> 
> Ingo Oeser

Sorry, I forgot. Sec ..

diff config/gen_unix.c.old config/gen_unix.c -u; diff -u
std/socket.d.old std/socket.d
- --- config/gen_unix.c.old       2007-09-12 06:33:55.000000000 +0200
+++ config/gen_unix.c   2007-09-12 06:29:01.000000000 +0200
@@ -667,6 +667,7 @@
     CES( MSG_OOB );
     CES( MSG_PEEK );
     CES( MSG_DONTROUTE );
+    CES( MSG_NOSIGNAL );
     printf("}\n");
     printf("\n");
 }
- --- std/socket.d.old    2007-09-11 03:05:54.000000000 +0200
+++ std/socket.d        2007-09-13 03:10:54.000000000 +0200
@@ -1335,6 +1335,11 @@
        //returns number of bytes actually sent, or -1 on error
        int send(void[] buf, SocketFlags flags)
        {
+               version(Windows) { }
+               else
+               {
+                       flags |= MSG_NOSIGNAL;
+               }
                int sent = .send(sock, buf.ptr, buf.length, cast(int)flags);
                return sent;
        }
@@ -1350,6 +1355,11 @@
         */
        int sendTo(void[] buf, SocketFlags flags, Address to)
        {
+               version(Windows) { }
+               else
+               {
+                       flags |= MSG_NOSIGNAL;
+               }
                int sent = .sendto(sock, buf.ptr, buf.length,
cast(int)flags, to.name(), to.nameLen());
                return sent;
        }
@@ -1365,6 +1375,11 @@
        /// ditto
        int sendTo(void[] buf, SocketFlags flags)
        {
+               version(Windows) { }
+               else
+               {
+                       flags |= MSG_NOSIGNAL;
+               }
                int sent = .sendto(sock, buf.ptr, buf.length,
cast(int)flags, null, 0);
                return sent;
        }

Excuse the copypaste, but I wasn't sure whether it was worth it making a
new private function for this.
 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6I6apEPJRr05fBERAkDXAKCaDYixAXUHIc31yvaPMAGNC46liACfZ1Za
wx9sEDj0PtbwQHct6B6GxfQ=
=rpSm
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-bugs mailing list