Check-in [a697a2954e]
Overview
Comment:Merged proper fix for mkClose() segfaulting in from P. Thoyts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a697a2954e480f8001f8707fee99116ce87bd187
User & Date: rkeene on 2010-10-18 17:56:31
Other Links: manifest | tags
Context
2010-10-21
13:00
KitCreator 0.5.3

Removed version control tag from release version check-in: 9ff996f870 user: rkeene tags: trunk, 0.5.3

2010-10-18
17:56
Merged proper fix for mkClose() segfaulting in from P. Thoyts check-in: a697a2954e user: rkeene tags: trunk
2010-10-17
17:27
Added link to home page from build page check-in: 626ffe0122 user: rkeene tags: trunk
Changes

Modified mk4tcl/patches/all/metakit-2.4.9.7-fixeventchannels-1pt.diff from [8e303e1d43] to [95a5c09a03].

     1      1   diff -uNr metakit-2.4.9.7.orig/tcl/mk4tcl.cpp metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.cpp
     2      2   --- metakit-2.4.9.7.orig/tcl/mk4tcl.cpp	2007-06-18 16:05:24.000000000 -0500
     3         -+++ metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.cpp	2010-10-16 16:21:41.000000000 -0500
     4         -@@ -182,6 +182,8 @@
            3  ++++ metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.cpp	2010-10-18 09:09:28.000000000 -0500
            4  +@@ -182,11 +182,14 @@
     5      5        Tcl_Channel _chan;
     6      6        int _validMask;
     7      7        int _watchMask;
     8      8   +    int _flags;
     9      9   +    SiasStrategy *_next;
           10  ++    MkWorkspace *_workspace;
    10     11        Tcl_Interp *_interp;
    11     12    
    12     13        SiasStrategy(c4_Storage &storage_, const c4_View &view_, const c4_BytesProp
    13         -@@ -259,23 +261,58 @@
           14  +       &memo_, int row_): _storage(storage_), _view(view_), _memo(memo_), _row
           15  +-      (row_), _position(0), _interp(0) {
           16  ++      (row_), _position(0), _interp(0), _next(0), _workspace(0) {
           17  +         // set up mapping if the memo itself is mapped in its entirety
           18  +         c4_Strategy &strat = storage_.Strategy();
           19  +         if (strat._mapStart != 0) {
           20  +@@ -259,23 +262,57 @@
    14     21    ///////////////////////////////////////////////////////////////////////////////
    15     22    // New in 1.2: channel interface to memo fields
    16     23    
    17     24   -typedef SiasStrategy MkChannel;
    18     25   -
    19     26    typedef struct {
    20     27      Tcl_Event header;
................................................................................
    39     46    
    40     47   +static void SetupProc(ClientData clientData, int flags) {
    41     48   +  MkWorkspace *ws = (MkWorkspace *)clientData;
    42     49   +  int msec = 10000;
    43     50   +  Tcl_Time blockTime = {0, 0};
    44     51   +  if (!(flags & TCL_FILE_EVENTS))
    45     52   +    return;
    46         -+  for (MkChannel *chan = ws->_chanList; chan != NULL; chan = chan->_next) {
           53  ++  if (ws->_chanList != 0)
    47     54   +    msec = 10;
    48         -+  }
    49     55   +  blockTime.sec = msec / 1000;
    50     56   +  blockTime.usec = (msec % 1000) * 1000;
    51     57   +  Tcl_SetMaxBlockTime(&blockTime);
    52     58   +}
    53     59   +
    54     60   +static void CheckProc(ClientData clientData, int flags) {
    55     61   +  MkWorkspace *ws = (MkWorkspace *)clientData;
................................................................................
    69     75   +    }
    70     76   +  }
    71     77   +}
    72     78   +
    73     79    static int mkEventFilter(Tcl_Event *evPtr, ClientData instanceData) {
    74     80      MkEvent *me = (MkEvent*)evPtr;
    75     81      MkChannel *chan = (MkChannel*)instanceData;
    76         -@@ -285,6 +322,16 @@
           82  +@@ -284,8 +321,21 @@
           83  + 
    77     84    static int mkClose(ClientData instanceData, Tcl_Interp *interp) {
    78     85      MkChannel *chan = (MkChannel*)instanceData;
           86  ++  MkWorkspace *ws = chan->_workspace;
           87  ++  MkChannel **tmpPtrPtr = &ws->_chanList;
    79     88    
           89  +   Tcl_DeleteEvents(mkEventFilter, (ClientData)chan);
           90  ++
    80     91   +  /* remove this channel from the package list */
    81         -+  if (interp) {
    82         -+    MkWorkspace *ws = (MkWorkspace*)Tcl_GetAssocData(interp, "mk4tcl", 0);
    83         -+    MkChannel **tmpPtrPtr = &ws->_chanList;
    84         -+    while (*tmpPtrPtr && *tmpPtrPtr != chan) {
    85         -+      tmpPtrPtr = &(*tmpPtrPtr)->_next;
    86         -+    }
    87         -+    *tmpPtrPtr = chan->_next;
           92  ++  while (*tmpPtrPtr && (*tmpPtrPtr != chan)) {
           93  ++    tmpPtrPtr = &(*tmpPtrPtr)->_next;
    88     94   +  }
    89         -+  
    90         -   Tcl_DeleteEvents(mkEventFilter, (ClientData)chan);
           95  ++  if (*tmpPtrPtr == chan) {
           96  ++      *tmpPtrPtr = chan->_next;
           97  ++      chan->_next = 0;
           98  ++  } else {
           99  ++      d4_assert(false);
          100  ++  }
    91    101      chan->_chan = 0;
    92    102      delete chan;
    93         -@@ -726,7 +773,7 @@
          103  + 
          104  +@@ -726,21 +776,24 @@
    94    105      ++generation; // make sure all cached paths refresh on next access
    95    106    }
    96    107    
    97    108   -MkWorkspace::MkWorkspace(Tcl_Interp *ip_): _interp(ip_) {
    98         -+MkWorkspace::MkWorkspace(Tcl_Interp *ip_): _interp(ip_), _chanList(NULL) {
          109  ++MkWorkspace::MkWorkspace(Tcl_Interp *ip_): _interp(ip_), _chanList(0) {
    99    110      new Item("", "", 0, _items, 0);
   100    111    
   101    112      // never uses entry zero (so atoi failure in ForgetPath is harmless)
   102         -@@ -741,6 +788,7 @@
          113  +   _usedRows = _usedBuffer.SetBufferClear(16); 
          114  +-    // no realloc for first 16 temp rows
          115  ++  // no realloc for first 16 temp rows
          116  + }
          117  + 
          118  + MkWorkspace::~MkWorkspace() {
          119  +   CleanupCommands();
          120  + 
          121  ++  d4_assert(_chanList == 0);
          122  ++
          123  +   for (int i = _items.GetSize(); --i >= 0;)
   103    124        delete Nth(i);
   104    125    
   105    126      // need this to prevent recursion in Tcl_DeleteAssocData in 8.2 (not 8.0!)
   106    127   +  Tcl_DeleteEventSource(SetupProc, CheckProc, this);
   107    128      Tcl_SetAssocData(_interp, "mk4tcl", 0, 0);
   108    129      Tcl_DeleteAssocData(_interp, "mk4tcl");
   109    130    }
   110         -@@ -2371,6 +2419,7 @@
          131  +@@ -2371,6 +2424,7 @@
   111    132    
   112    133      mkChan->_watchMask = 0;
   113    134      mkChan->_validMask = mode;
   114    135   +  mkChan->_flags = 0;
   115    136      mkChan->_interp = interp;
   116    137      mkChan->_chan = Tcl_CreateChannel(&mkChannelType, buffer, (ClientData)mkChan,
   117    138        mode);
   118         -@@ -2380,6 +2429,10 @@
   119         - 
   120         -   Tcl_RegisterChannel(interp, mkChan->_chan);
          139  +@@ -2383,6 +2437,11 @@
          140  +   if (_error)
          141  +     return _error;
   121    142    
   122    143   +  /* insert this channel at the front of the workspace channels list */
          144  ++  mkChan->_workspace = &work;
   123    145   +  mkChan->_next = work._chanList;
   124    146   +  work._chanList = mkChan;
   125    147   +
   126         -   if (_error)
   127         -     return _error;
          148  +   KeepRef o = tcl_NewStringObj(buffer);
          149  +   return tcl_SetObjResult(o);
          150  + }
          151  +@@ -2579,6 +2638,7 @@
          152  + }
          153  + 
          154  + static void ExitProc(ClientData cd_) {
          155  ++  Tcl_DeleteEventSource(SetupProc, CheckProc, cd_);
          156  +   delete (MkWorkspace*)cd_;
          157  + }
   128    158    
   129         -@@ -2603,6 +2656,7 @@
          159  +@@ -2603,6 +2663,7 @@
   130    160        // since that does not seem to trigger exitproc handling (!)
   131    161        Tcl_SetAssocData(interp, "mk4tcl", DelProc, ws);
   132    162        Tcl_CreateExitHandler(ExitProc, ws);
   133    163   +    Tcl_CreateEventSource(SetupProc, CheckProc, ws);
   134    164      }
   135    165    
   136    166      // this list must match the "CmdDef defTab []" above.
   137         -@@ -2648,3 +2702,11 @@
          167  +@@ -2648,3 +2709,11 @@
   138    168    }
   139    169    
   140    170    ///////////////////////////////////////////////////////////////////////////////
   141    171   +
   142    172   +/*
   143    173   + * Local variables:
   144    174   + * mode: c
   145    175   + * c-basic-offset: 2
   146    176   + * indent-tabs-mode: nil
   147    177   + * End:
   148    178   + */
   149    179   diff -uNr metakit-2.4.9.7.orig/tcl/mk4tcl.h metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.h
   150    180   --- metakit-2.4.9.7.orig/tcl/mk4tcl.h	2007-06-15 18:26:40.000000000 -0500
   151         -+++ metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.h	2010-10-16 16:19:00.000000000 -0500
          181  ++++ metakit-2.4.9.7-1ptrsk/tcl/mk4tcl.h	2010-10-18 09:09:00.000000000 -0500
   152    182   @@ -205,6 +205,9 @@
   153    183    ///////////////////////////////////////////////////////////////////////////////
   154    184    // A workspace manages a number of storage objects and their associated paths.
   155    185    
   156    186   +class SiasStrategy;
   157    187   +typedef SiasStrategy MkChannel;
   158    188   +