summaryrefslogtreecommitdiffstats
path: root/mac/tclMacSock.c
diff options
context:
space:
mode:
authorstanton <stanton>1999-04-15 22:38:46 (GMT)
committerstanton <stanton>1999-04-15 22:38:46 (GMT)
commit743017523886608c1403479b0676d469b8f998ac (patch)
treee29ecad719da73c67d437be2a057cc01dca684e9 /mac/tclMacSock.c
parentae56f9fc8840d99814f8fc8986fe6445ec9a57e6 (diff)
downloadtcl-743017523886608c1403479b0676d469b8f998ac.zip
tcl-743017523886608c1403479b0676d469b8f998ac.tar.gz
tcl-743017523886608c1403479b0676d469b8f998ac.tar.bz2
* Merge 8.0.5 changes:
- Mac changes for final release - Minor fixes to tools configure file * win/tclWinSock.c: Apply patch to allow write access to a socket if FD_WRITE is sent but FD_CONNECT is not. Some strange problem with either Win32 or a socket driver. [Bug: 1664 1776]
Diffstat (limited to 'mac/tclMacSock.c')
-rw-r--r--mac/tclMacSock.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/mac/tclMacSock.c b/mac/tclMacSock.c
index b36ae1d..17436da 100644
--- a/mac/tclMacSock.c
+++ b/mac/tclMacSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMacSock.c,v 1.2 1998/09/14 18:40:06 stanton Exp $
+ * RCS: @(#) $Id: tclMacSock.c,v 1.3 1999/04/15 22:38:47 stanton Exp $
*/
#include "tclInt.h"
@@ -82,6 +82,9 @@ typedef struct TcpState {
rdsEntry rdsarray[5+1]; /* Array used when cleaning out recieve
* buffers on a closing socket. */
Tcl_Channel channel; /* Channel associated with this socket. */
+ int writeBufferSize; /* Size of buffer to hold data for
+ * asynchronous writes. */
+ void *writeBuffer; /* Buffer for async write data. */
struct TcpState *nextPtr; /* The next socket on the global socket
* list. */
} TcpState;
@@ -1210,8 +1213,26 @@ TcpOutput(
if (toWrite < amount) {
amount = toWrite;
}
+
+ /* We need to copy the data, otherwise the caller may overwrite
+ * the buffer in the middle of our asynchronous call
+ */
+
+ if (amount > statePtr->writeBufferSize) {
+ /*
+ * need to grow write buffer
+ */
+
+ if (statePtr->writeBuffer != (void *) NULL) {
+ ckfree(statePtr->writeBuffer);
+ }
+ statePtr->writeBuffer = (void *) ckalloc(amount);
+ statePtr->writeBufferSize = amount;
+ }
+ memcpy(statePtr->writeBuffer, buf, amount);
+ statePtr->dataSegment[0].ptr = statePtr->writeBuffer;
+
statePtr->dataSegment[0].length = amount;
- statePtr->dataSegment[0].ptr = buf;
statePtr->dataSegment[1].length = 0;
InitMacTCPParamBlock(&statePtr->pb, TCPSend);
statePtr->pb.ioCompletion = completeUPP;
@@ -1479,6 +1500,8 @@ NewSocketInfo(
statePtr->watchMask = 0;
statePtr->acceptProc = (Tcl_TcpAcceptProc *) NULL;
statePtr->acceptProcData = (ClientData) NULL;
+ statePtr->writeBuffer = (void *) NULL;
+ statePtr->writeBufferSize = 0;
statePtr->nextPtr = socketList;
socketList = statePtr;
return statePtr;
@@ -1516,6 +1539,11 @@ FreeSocketInfo(
}
}
}
+
+ if (statePtr->writeBuffer != (void *) NULL) {
+ ckfree(statePtr->writeBuffer);
+ }
+
ckfree((char *) statePtr);
}