Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | merge bug-67a5eabbd3d1 |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
9bcec7cd880540c339de2f702bbf6748 |
User & Date: | pooryorick 2019-04-24 04:52:22.680 |
References
2024-08-13
| ||
19:26 | • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status still Closed with 6 other changes artifact: f683832177 user: jan.nijtmans | |
2024-05-29
| ||
09:44 | Fix [18f4a94d03], by reverting [9bcec7cd880540c3], which caused it. See [https://core.tcl-lang.org/t... check-in: 8d4d978bd3 user: jan.nijtmans tags: core-8-branch | |
2024-04-18
| ||
15:32 | Fix [18f4a94d03] by backing out [9bcec7cd880540c3] (again) check-in: a2633b5cc5 user: jan.nijtmans tags: bug-18f4a94d03 | |
2021-06-15
| ||
14:54 | Fix [18f4a94d03] by backing out [9bcec7cd880540c3] check-in: a785b5bf5e user: jan.nijtmans tags: core-8-branch | |
14:52 | Fix [18f4a94d03] by backing out [9bcec7cd880540c3] Closed-Leaf check-in: ee3930e93a user: jan.nijtmans tags: bug-18f4a94d03 | |
12:56 | Fix [18f4a94d03] by backout out [9bcec7cd880540c3] check-in: 3f466e55c8 user: jan.nijtmans tags: bug-18f4a94d03 | |
12:46 | • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status still Open with 4 other changes artifact: c3d29a0d48 user: jan.nijtmans | |
Context
2021-06-15
| ||
12:56 | Fix [18f4a94d03] by backout out [9bcec7cd880540c3] check-in: 3f466e55c8 user: jan.nijtmans tags: bug-18f4a94d03 | |
2019-04-27
| ||
07:19 | Fix for de232b49f2, write-only nonblocking refchan and Tcl internal buffers. check-in: d0dd6d19a4 user: pooryorick tags: bug-de232b49f2 | |
2019-04-24
| ||
14:29 | Plug memleak in [lpop] due to mishandling the unconventional recounting practices of TclLsetFlat(). check-in: ec114b14ff user: dgp tags: core-8-branch | |
04:52 | merge bug-67a5eabbd3d1 check-in: 9bcec7cd88 user: pooryorick tags: core-8-branch | |
04:04 | Add missed timer cleanup in tclIORChan.c/ReflectClose. Closed-Leaf check-in: ff99dcf804 user: pooryorick tags: bug-67a5eabbd3d1 | |
2019-04-23
| ||
06:50 | timerate: code style, doc style check-in: c4804bce46 user: dkf tags: core-8-branch | |
Changes
Changes to generic/tclIORChan.c.
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | int mode, int *errorCodePtr); static int ReflectGetOption(ClientData clientData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static int ReflectSetOption(ClientData clientData, Tcl_Interp *interp, const char *optionName, const char *newValue); /* * The C layer channel type/driver definition used by the reflection. This is * a version 3 structure. */ static const Tcl_ChannelType tclRChannelType = { | > > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | int mode, int *errorCodePtr); static int ReflectGetOption(ClientData clientData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static int ReflectSetOption(ClientData clientData, Tcl_Interp *interp, const char *optionName, const char *newValue); static void TimerRunRead(ClientData clientData); static void TimerRunWrite(ClientData clientData); /* * The C layer channel type/driver definition used by the reflection. This is * a version 3 structure. */ static const Tcl_ChannelType tclRChannelType = { |
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | int mode; /* Mask of R/W mode */ int interest; /* Mask of events the channel is interested * in. */ int dead; /* Boolean signal that some operations * should no longer be attempted. */ /* * Note regarding the usage of timers. * * Most channel implementations need a timer in the C level to ensure that * data in buffers is flushed out through the generation of fake file * events. * * See 'rechan', 'memchan', etc. * | > > > > > > > > > > > < < | < | > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | int mode; /* Mask of R/W mode */ int interest; /* Mask of events the channel is interested * in. */ int dead; /* Boolean signal that some operations * should no longer be attempted. */ Tcl_TimerToken readTimer; /* A token for the timer that is scheduled in order to call Tcl_NotifyChannel when the channel is readable */ Tcl_TimerToken writeTimer; /* A token for the timer that is scheduled in order to call Tcl_NotifyChannel when the channel is writable */ /* * Note regarding the usage of timers. * * Most channel implementations need a timer in the C level to ensure that * data in buffers is flushed out through the generation of fake file * events. * * See 'rechan', 'memchan', etc. * * A timer is used here as well in order to ensure at least on pass through * the event loop when a channel becomes ready. See issues 67a5eabbd3d1 and * ef28eb1f1516. */ } ReflectedChannel; /* * Structure of the table maping from channel handles to reflected * channels. Each interpreter which has the handler command for one or more * reflected channels records them in such a table, so that 'chan postevent' |
︙ | ︙ | |||
916 917 918 919 920 921 922 | /* * We have the channel and the events to post. */ #if TCL_THREADS if (rcPtr->owner == rcPtr->thread) { #endif | | > > > > > > > > > > > | 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | /* * We have the channel and the events to post. */ #if TCL_THREADS if (rcPtr->owner == rcPtr->thread) { #endif if (events & TCL_READABLE) { if (rcPtr->readTimer == NULL) { rcPtr->readTimer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, TimerRunRead, rcPtr); } } if (events & TCL_WRITABLE) { if (rcPtr->writeTimer == NULL) { rcPtr->writeTimer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, TimerRunWrite, rcPtr); } } #if TCL_THREADS } else { ReflectEvent *ev = ckalloc(sizeof(ReflectEvent)); ev->header.proc = ReflectEventRun; ev->events = events; ev->rcPtr = rcPtr; |
︙ | ︙ | |||
963 964 965 966 967 968 969 970 971 972 973 974 975 976 | Tcl_ResetResult(interp); return TCL_OK; #undef CHAN #undef EVENT } /* * Channel error message marshalling utilities. */ static Tcl_Obj * MarshallError( | > > > > > > > > > > > > > > > > > > | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | Tcl_ResetResult(interp); return TCL_OK; #undef CHAN #undef EVENT } static void TimerRunRead( ClientData clientData) { ReflectedChannel *rcPtr = clientData; rcPtr->readTimer = NULL; Tcl_NotifyChannel(rcPtr->chan, TCL_READABLE); } static void TimerRunWrite( ClientData clientData) { ReflectedChannel *rcPtr = clientData; rcPtr->writeTimer = NULL; Tcl_NotifyChannel(rcPtr->chan, TCL_WRITABLE); } /* * Channel error message marshalling utilities. */ static Tcl_Obj * MarshallError( |
︙ | ︙ | |||
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 | #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; if (tctPtr && tctPtr != &tclRChannelType) { ckfree(tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel); return EOK; } /* * Are we in the correct thread? */ | > > > > > > | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 | #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; if (tctPtr && tctPtr != &tclRChannelType) { ckfree(tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } if (rcPtr->readTimer != NULL) { Tcl_DeleteTimerHandler(rcPtr->readTimer); } if (rcPtr->writeTimer != NULL) { Tcl_DeleteTimerHandler(rcPtr->writeTimer); } Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel); return EOK; } /* * Are we in the correct thread? */ |
︙ | ︙ | |||
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | } #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; if (tctPtr && tctPtr != &tclRChannelType) { ckfree(tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel); return (result == TCL_OK) ? EOK : EINVAL; } /* *---------------------------------------------------------------------- * | > > > > > > | 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | } #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; if (tctPtr && tctPtr != &tclRChannelType) { ckfree(tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } if (rcPtr->readTimer != NULL) { Tcl_DeleteTimerHandler(rcPtr->readTimer); } if (rcPtr->writeTimer != NULL) { Tcl_DeleteTimerHandler(rcPtr->writeTimer); } Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel); return (result == TCL_OK) ? EOK : EINVAL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 | rcPtr = ckalloc(sizeof(ReflectedChannel)); /* rcPtr->chan: Assigned by caller. Dummy data here. */ rcPtr->chan = NULL; rcPtr->interp = interp; rcPtr->dead = 0; #if TCL_THREADS rcPtr->thread = Tcl_GetCurrentThread(); #endif rcPtr->mode = mode; rcPtr->interest = 0; /* Initially no interest registered */ /* ASSERT: cmdpfxObj is a Tcl List */ | > > | 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 | rcPtr = ckalloc(sizeof(ReflectedChannel)); /* rcPtr->chan: Assigned by caller. Dummy data here. */ rcPtr->chan = NULL; rcPtr->interp = interp; rcPtr->dead = 0; rcPtr->readTimer = 0; rcPtr->writeTimer = 0; #if TCL_THREADS rcPtr->thread = Tcl_GetCurrentThread(); #endif rcPtr->mode = mode; rcPtr->interest = 0; /* Initially no interest registered */ /* ASSERT: cmdpfxObj is a Tcl List */ |
︙ | ︙ |
Changes to tests/ioCmd.test.
︙ | ︙ | |||
926 927 928 929 930 931 932 933 934 935 936 937 938 939 | return -code return $args } proc onfinal {} { upvar args hargs if {[lindex $hargs 0] ne "finalize"} {return} return -code return "" } } # Set everything up in the main thread. eval $helperscript # --- --- --- --------- --------- --------- # method finalize | > > > > > > > > > > > | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | return -code return $args } proc onfinal {} { upvar args hargs if {[lindex $hargs 0] ne "finalize"} {return} return -code return "" } proc onwatch {} { upvar args hargs lassign $hargs watch chan eventspec if {$watch ne "watch"} return foreach spec $eventspec { chan postevent $chan $spec } return } } # Set everything up in the main thread. eval $helperscript # --- --- --- --------- --------- --------- # method finalize |
︙ | ︙ | |||
1998 1999 2000 2001 2002 2003 2004 | rename foo {} set res } -result {{unmatched open brace in list}} test iocmd-31.6 {chan postevent, posted events do happen} -match glob -body { set res {} proc foo {args} {oninit; onfinal; track; return} set c [chan create {r w} foo] | > | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > | 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 | rename foo {} set res } -result {{unmatched open brace in list}} test iocmd-31.6 {chan postevent, posted events do happen} -match glob -body { set res {} proc foo {args} {oninit; onfinal; track; return} set c [chan create {r w} foo] set tock {} note [fileevent $c readable {lappend res TOCK; set tock 1}] set stop [after 10000 {lappend res TIMEOUT; set tock 1}] after 1000 {note [chan postevent $c r]} vwait ::tock catch {after cancel $stop} close $c rename foo {} set res } -result {{watch rc* read} {} {} TOCK {watch rc* {}}} test iocmd-31.7 {chan postevent, posted events do happen} -match glob -body { set res {} proc foo {args} {oninit; onfinal; track; return} set c [chan create {r w} foo] note [fileevent $c writable {lappend res TOCK; set tock 1}] set stop [after 10000 {lappend res TIMEOUT; set tock 1}] after 1000 {note [chan postevent $c w]} vwait ::tock catch {after cancel $stop} close $c rename foo {} set res } -result {{watch rc* write} {} {} TOCK {watch rc* {}}} test iocmd-31.8 {chan postevent after close throws error} -match glob -setup { proc foo {args} {oninit; onfinal; track; return} proc dummy args { return } set c [chan create {r w} foo] fileevent $c readable dummy } -body { close $c chan postevent $c read } -cleanup { rename foo {} rename dummy {} } -returnCodes error -result {can not find reflected channel named "rc*"} test iocmd-31.9 { chan postevent call to current coroutine see 67a5eabbd3d1 } -match glob -body { set res {} proc foo {args} {oninit; onwatch; onfinal; track; return} set c [chan create {r w} foo] after 0 [list ::apply [list c { coroutine c1 ::apply [list c { chan event $c readable [list [info coroutine]] yield set ::done READING } [namespace current]] $c } [namespace current]] $c] set stop [after 10000 {set done TIMEOUT}] vwait ::done catch {after cancel $stop} lappend res $done close $c rename foo {} set res } -result {{watch rc* read} READING {watch rc* {}}} # --- === *** ########################### # 'Pull the rug' tests. Create channel in a interpreter A, move to # other interpreter B, destroy the origin interpreter (A) before or # during access from B. Must not crash, must return proper errors. test iocmd-32.0 {origin interpreter of moved channel gone} -match glob -body { |
︙ | ︙ |