www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2835] New: std.socket.TcpSocket.accept blocks forever

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835

           Summary: std.socket.TcpSocket.accept blocks forever
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: graham.stjack internode.on.net


The attached code works in 2.0.26 and blocks on accept in 2.0.27


-- 
Apr 14 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835





------- Comment #1 from graham.stjack internode.on.net  2009-04-14 16:39 -------
Created an attachment (id=322)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=322&action=view)
Test case


-- 
Apr 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


unknown simplemachines.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unknown simplemachines.org
            Summary|std.socket.TcpSocket.accept |std.socket.TcpSocket.connect
                   |blocks forever              |doesn't actually connect




------- Comment #2 from unknown simplemachines.org  2009-04-15 12:40 -------
Just a drive-by.  Simplified testcase:

---
import std.socket, std.stdio;

void main()
{
        // Replace 12345 with any unused port.
        auto address = new InternetAddress("127.0.0.1", 12345);

        try
        {
                auto client = new TcpSocket();
                client.connect(address);

                writefln("Where's my error?");
        }
        catch (SocketException)
                writefln("Success");
}
---

Testcase succeeds on Windows, but not Linux, using 2.028 and CentOS 5.3.  Most
likely, incorrect size of the sockaddr_in struct or something.

-[Unknown]


-- 
Apr 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835





------- Comment #3 from unknown simplemachines.org  2009-04-15 21:03 -------
Created an attachment (id=324)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=324&action=view)
Set sin_family properly.

Pruning down some C-style socket code, I determined that sin_family was the
deciding factor on this behavior.  Unfortunately, it is unclear to me why this
would've regressed from 2.026 (since sin_family has never been set?)

Graham, you can work around this issue and verify the fix by recompiling phobos
or by writing a subclass for InternetAddress, e.g.:

---
import std.c.linux.socket, core.sys.posix.sys.socket;
import std.socket;

class MyInternetAddress: InternetAddress
{
        this(string addr, ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(addr, port);
        }

        this(uint addr, ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(addr, port);
        }

        this(ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(port);
        }
}
---

If you could verify this fixes your issue, it would be appreciated.

Thanks,
-[Unknown]


-- 
Apr 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835





------- Comment #4 from graham.stjack internode.on.net  2009-04-16 20:00 -------
It did indeed fix the issue. My (improved) test code now works in 2.026 and
2.028 when I use the workaround.


-- 
Apr 16 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Foy Savas <foysavas gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foysavas gmail.com


--- Comment #5 from Foy Savas <foysavas gmail.com> 2009-12-24 19:48:56 PST ---
I can confirm this patch applying cleanly to the latest Phobos. Can we get this
in for the next DMD release? It's no exaggeration to say that working sockets
to some are both their bread and butter.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 24 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


iorlas <denis.tomilin gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |4ybaka gmail.com


--- Comment #6 from iorlas <denis.tomilin gmail.com> 2010-02-05 15:46:27 PST ---
*** Issue 3649 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835



--- Comment #7 from Alexey Ivanov <aifgi90 gmail.com> 2010-02-14 07:18:56 PST
---
Created an attachment (id=567)
patch for std.socket

Patch for std.socket

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Shin Fujishiro <rsinfu gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #8 from Shin Fujishiro <rsinfu gmail.com> 2010-05-23 01:34:23 PDT
---
Fixed in svn r1543.
Thanks for the patches!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Sohgo Takeuchi <sohgo sohgo.dyndns.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sohgo sohgo.dyndns.org


--- Comment #9 from Sohgo Takeuchi <sohgo sohgo.dyndns.org> 2010-05-23 02:43:15
PDT ---
Phobos1 has the same problem.
I am happy that this fix will be applied to the phobos1 too.
Thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835



--- Comment #10 from Sohgo Takeuchi <sohgo sohgo.dyndns.org> 2010-05-23
22:28:02 PDT ---
I have looked at the Changeset 1548.
Thanks for applying this fix to the phobos1.

BTW, Issue 3489 is also a same report of this issue I think.
So you can close the Issue 3489 too.

Thank you.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835



--- Comment #11 from Shin Fujishiro <rsinfu gmail.com> 2010-05-23 23:29:58 PDT
---
(In reply to comment #10)
 BTW, Issue 3489 is also a same report of this issue I think.
 So you can close the Issue 3489 too.

I see. Thank you for pointing it out to me. :D -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2010