diff options
author | dgp <dgp@users.sourceforge.net> | 2015-08-12 16:37:28 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-08-12 16:37:28 (GMT) |
commit | 2c66fc643c1e662526ad4cd59b0b1836b171a35c (patch) | |
tree | abbfa3a84b54430494553a4e1a1319b2ab228cdb /generic/tclIORChan.c | |
parent | 07ee24f589ea3b7d220a8fa59fc23481062a2c12 (diff) | |
download | tcl-2c66fc643c1e662526ad4cd59b0b1836b171a35c.zip tcl-2c66fc643c1e662526ad4cd59b0b1836b171a35c.tar.gz tcl-2c66fc643c1e662526ad4cd59b0b1836b171a35c.tar.bz2 |
New test io-53.18 adapted from demo script in [32ae34e63a]. This test
segfaults without changes to source code. This checkin also contains
a revised implementationf of [chan postevent] that stops calling
Tcl_NotifyChannel() directly, and queues an event to do it instead.
This stops the segfault, but causes tests iocmd-31.[67] to fail.
Need advice on whether that matters.
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r-- | generic/tclIORChan.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index bbb5b88..6592f9e 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -741,6 +741,24 @@ TclChanCreateObjCmd( *---------------------------------------------------------------------- */ +typedef struct PostEvent { + Tcl_Event event; /* Basic event data, has to be first item */ + Tcl_Channel chan; + int events; +} PostEvent; + +static int +CallNotify( + Tcl_Event *evPtr, + int flags) +{ + PostEvent *pevPtr = (PostEvent *)evPtr; + + Tcl_NotifyChannel(pevPtr->chan, pevPtr->events); + TclChannelRelease(pevPtr->chan); + return 1; +} + int TclChanPostEventObjCmd( ClientData clientData, @@ -769,6 +787,7 @@ TclChanPostEventObjCmd( int events; /* Mask of events to post */ ReflectedChannelMap* rcmPtr; /* Map of reflected channels with handlers in this interp */ Tcl_HashEntry* hPtr; /* Entry in the above map */ + PostEvent *pevPtr; /* * Number of arguments... @@ -857,7 +876,12 @@ TclChanPostEventObjCmd( * We have the channel and the events to post. */ - Tcl_NotifyChannel(chan, events); + pevPtr = (PostEvent *)ckalloc(sizeof(PostEvent)); + pevPtr->event.proc = CallNotify; + pevPtr->chan = chan; + pevPtr->events = events; + TclChannelPreserve(chan); + Tcl_QueueEvent((Tcl_Event *)pevPtr, TCL_QUEUE_HEAD); /* * Squash interp results left by the event script. |