Check-in [0f347a7892]

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

Overview
Comment:When polling MacTCP connections, check the connection state and if the far end has sent a FIN pass that up to the plug. TODO: handle less graceful connection closures.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0f347a7892153d37a3ea97aad7ff6edf90a3ccfa
User & Date: ben 2003-01-11 11:31:59.000
Context
2003-01-11
11:36
Calling plug_closing() is highly likely to result in a call to sk_close(), so arrange that mactcp_poll() can cope with that and not access freed memory when it happens. check-in: 54ae5e5df7 user: ben tags: trunk
11:31
When polling MacTCP connections, check the connection state and if the far end has sent a FIN pass that up to the plug. TODO: handle less graceful connection closures. check-in: 0f347a7892 user: ben tags: trunk
08:20
Move the prototype for platform_get_x11_auth() from x11fwd.c to ssh.h so that it can be checked against the implementation. check-in: 81acda317b user: ben tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to mac/mtcpnet.c.
138
139
140
141
142
143
144













145
146
147
148
149
150
151
			     (addr), (addrStr))
#define AddrToStr(addr, addrStr)					\
    InvokeAddrToStrUPP(ADDRTOSTR, addr, addrStr,			\
		       (AddrToStrUPP)*mactcp.dnr_handle)

/* End of AddressXlation.h bits */














struct Socket_tag {
    struct socket_function_table *fn;
    /* the above variable absolutely *must* be the first in this structure */
    StreamPtr s;
    OSErr err;
    Plug plug;
    void *private_ptr;







>
>
>
>
>
>
>
>
>
>
>
>
>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
			     (addr), (addrStr))
#define AddrToStr(addr, addrStr)					\
    InvokeAddrToStrUPP(ADDRTOSTR, addr, addrStr,			\
		       (AddrToStrUPP)*mactcp.dnr_handle)

/* End of AddressXlation.h bits */

/* TCP connection states, mysteriously missing from <MacTCP.h> */
#define TCPS_CLOSED		0
#define TCPS_LISTEN		2
#define TCPS_SYN_RECEIVED	4
#define TCPS_SYN_SENT		6
#define TCPS_ESTABLISHED	8
#define TCPS_FIN_WAIT_1		10
#define TCPS_FIN_WAIT_2		12
#define TCPS_CLOSE_WAIT		14
#define TCPS_CLOSING		16
#define TCPS_LAST_ACK		18
#define TCPS_TIME_WAIT		20

struct Socket_tag {
    struct socket_function_table *fn;
    /* the above variable absolutely *must* be the first in this structure */
    StreamPtr s;
    OSErr err;
    Plug plug;
    void *private_ptr;
602
603
604
605
606
607
608
609
610





611
612
613
614
615
616
617
	    pb.csParam.status.userDataPtr = (Ptr)s;
	    s->err = PBControlSync((ParmBlkPtr)&pb);
	    if (s->err != noErr)
		goto next_socket;
	    if (pb.csParam.status.amtUnreadData == 0)
		break;
	    mactcp_recv(s, pb.csParam.status.amtUnreadData);
	    /* Should check connectionState in case remote has closed */
	} while (TRUE);





      next_socket:
	;
    }
}

static void mactcp_recv(Actual_Socket s, size_t len)
{







<

>
>
>
>
>







615
616
617
618
619
620
621

622
623
624
625
626
627
628
629
630
631
632
633
634
	    pb.csParam.status.userDataPtr = (Ptr)s;
	    s->err = PBControlSync((ParmBlkPtr)&pb);
	    if (s->err != noErr)
		goto next_socket;
	    if (pb.csParam.status.amtUnreadData == 0)
		break;
	    mactcp_recv(s, pb.csParam.status.amtUnreadData);

	} while (TRUE);
	switch (pb.csParam.status.connectionState) {
	  case TCPS_CLOSE_WAIT:
	    /* Remote end has sent us a FIN */
	    plug_closing(s->plug, NULL, 0, 0);
	}
      next_socket:
	;
    }
}

static void mactcp_recv(Actual_Socket s, size_t len)
{