diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-10-12 15:22:44 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-10-12 15:22:44 (GMT) |
commit | 6350f481ab938dedb69141f3bb805baa36c1debe (patch) | |
tree | 916acbfb60e344257b50f591d11cfa38de2e64ff /unix | |
parent | f6d894829ab83201b39202a1f7d9a2cd013d151e (diff) | |
parent | 830088187a0558fe12fec8d7691a3d4cfa030ebb (diff) | |
download | tcl-6350f481ab938dedb69141f3bb805baa36c1debe.zip tcl-6350f481ab938dedb69141f3bb805baa36c1debe.tar.gz tcl-6350f481ab938dedb69141f3bb805baa36c1debe.tar.bz2 |
Merge 8.7
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixChan.c | 24 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 18 |
2 files changed, 34 insertions, 8 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index eea1453..0d4acf2 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -278,7 +278,7 @@ FileInputProc( */ do { - bytesRead = read(fsPtr->fd, buf, (size_t)toRead); + bytesRead = read(fsPtr->fd, buf, toRead); } while ((bytesRead < 0) && (errno == EINTR)); if (bytesRead < 0) { @@ -327,7 +327,7 @@ FileOutputProc( return 0; } - written = write(fsPtr->fd, buf, (size_t)toWrite); + written = write(fsPtr->fd, buf, toWrite); if (written >= 0) { return written; } @@ -480,6 +480,20 @@ FileWideSeekProc( *---------------------------------------------------------------------- */ +/* + * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc, + * so do not pass it to directly to Tcl_CreateFileHandler. + * Instead, pass a wrapper which is a Tcl_FileProc. + */ +static void +FileWatchNotifyChannelWrapper( + void *clientData, + int mask) +{ + Tcl_Channel channel = (Tcl_Channel)clientData; + Tcl_NotifyChannel(channel, mask); +} + static void FileWatchProc( void *instanceData, /* The file state. */ @@ -490,15 +504,13 @@ FileWatchProc( FileState *fsPtr = (FileState *)instanceData; /* - * Make sure we only register for events that are valid on this file. Note - * that we are passing Tcl_NotifyChannel directly to Tcl_CreateFileHandler - * with the channel pointer as the client data. + * Make sure we only register for events that are valid on this file. */ mask &= fsPtr->validMask; if (mask) { Tcl_CreateFileHandler(fsPtr->fd, mask, - (Tcl_FileProc *) Tcl_NotifyChannel, fsPtr->channel); + FileWatchNotifyChannelWrapper, fsPtr->channel); } else { Tcl_DeleteFileHandler(fsPtr->fd); } diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 4e8a758..1e2f3b0 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -1216,6 +1216,20 @@ PipeOutputProc( *---------------------------------------------------------------------- */ +/* + * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc, + * so do not pass it to directly to Tcl_CreateFileHandler. + * Instead, pass a wrapper which is a Tcl_FileProc. + */ +static void +PipeWatchNotifyChannelWrapper( + void *clientData, + int mask) +{ + Tcl_Channel channel = (Tcl_Channel)clientData; + Tcl_NotifyChannel(channel, mask); +} + static void PipeWatchProc( void *instanceData, /* The pipe state. */ @@ -1230,7 +1244,7 @@ PipeWatchProc( newmask = mask & (TCL_READABLE | TCL_EXCEPTION); if (newmask) { Tcl_CreateFileHandler(GetFd(psPtr->inFile), newmask, - (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel); + PipeWatchNotifyChannelWrapper, psPtr->channel); } else { Tcl_DeleteFileHandler(GetFd(psPtr->inFile)); } @@ -1239,7 +1253,7 @@ PipeWatchProc( newmask = mask & (TCL_WRITABLE | TCL_EXCEPTION); if (newmask) { Tcl_CreateFileHandler(GetFd(psPtr->outFile), newmask, - (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel); + PipeWatchNotifyChannelWrapper, psPtr->channel); } else { Tcl_DeleteFileHandler(GetFd(psPtr->outFile)); } |