Tcl Source Code

Check-in [c2331d8741]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix compile error if SO_REUSEPORT not supported. Put command options in alphabetical order
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-456 fork
Files: files | file ages | folders
SHA1: c2331d8741c8d6badbb0a3727fa91d73e95bfb4d
User & Date: jan.nijtmans 2016-11-24 13:18:10
Context
2016-11-24
16:21
merge fork Closed-Leaf check-in: 5291e16a6a user: jan.nijtmans tags: tip-456 fork
13:18
Fix compile error if SO_REUSEPORT not supported. Put command options in alphabetical order check-in: c2331d8741 user: jan.nijtmans tags: tip-456 fork
12:47
Implement the whole TIP 456 specification.

Also introduces the `-reuseaddr' and `-reuseport' option... check-in: e4212ca03b user: limeboy tags: tip-456

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclIOCmd.c.

1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
Tcl_SocketObjCmd(
    ClientData notUsed,		/* Not used. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    static const char *const socketOptions[] = {
	"-async", "-myaddr", "-myport", "-server", "-reuseaddr", "-reuseport",
	NULL
    };
    enum socketOptions {
	SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER, SKT_REUSEADDR,
	SKT_REUSEPORT
    };
    int optionIndex, a, server = 0, port, myport = 0, async = 0;
    unsigned int flags = 0;
    const char *host, *myaddr = NULL;
    Tcl_Obj *script = NULL;
    Tcl_Channel chan;







|



|
|







1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
Tcl_SocketObjCmd(
    ClientData notUsed,		/* Not used. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    static const char *const socketOptions[] = {
	"-async", "-myaddr", "-myport", "-reuseaddr", "-reuseport", "-server",
	NULL
    };
    enum socketOptions {
	SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_REUSEADDR, SKT_REUSEPORT,
	SKT_SERVER
    };
    int optionIndex, a, server = 0, port, myport = 0, async = 0;
    unsigned int flags = 0;
    const char *host, *myaddr = NULL;
    Tcl_Obj *script = NULL;
    Tcl_Channel chan;

Changes to unix/tclUnixSock.c.

1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529

1530
1531
1532
1533
1534
1535
1536
#ifndef SO_REUSEPORT
	    /*
	     * If the platform doesn't support the SO_REUSEPORT flag we can't do
	     * much beside erroring out.
	     */
	    errorMsg = "SO_REUSEPORT isn't supported by this platform";
	    goto error;
#endif
	    optvalue = 1;
	    (void) setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
			      (char *) &optvalue, sizeof(optvalue));

	}

        /*
         * Make sure we use the same port number when opening two server
         * sockets for IPv4 and IPv6 on a random port.
         *
         * As sockaddr_in6 uses the same offset and size for the port member






|



>







1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
#ifndef SO_REUSEPORT
	    /*
	     * If the platform doesn't support the SO_REUSEPORT flag we can't do
	     * much beside erroring out.
	     */
	    errorMsg = "SO_REUSEPORT isn't supported by this platform";
	    goto error;
#else
	    optvalue = 1;
	    (void) setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
			      (char *) &optvalue, sizeof(optvalue));
#endif
	}

        /*
         * Make sure we use the same port number when opening two server
         * sockets for IPv4 and IPv6 on a random port.
         *
         * As sockaddr_in6 uses the same offset and size for the port member