System.Data.SQLite
Check-in [384b2aecc2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Also prevent repeated calls into GetAssemblyDirectory and GetXmlConfigFileName when their respective searches are not successful.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 384b2aecc24bf1f2f46fd922fc4dced7a97f2096
User & Date: mistachkin 2017-05-12 20:43:17
References
2017-05-12
20:45
Cherrypick of [384b2aecc24bf1], avoid repeated calls into GetAssemblyDirectory/GetXmlConfigFileName for null returns. check-in: 6058d5f357 user: mistachkin tags: branch-1.0.105
Context
2017-05-13
05:42
Merge in applicable changes from the 1.0.105.1 release. check-in: c2adf5a112 user: mistachkin tags: trunk
2017-05-12
20:45
Cherrypick of [384b2aecc24bf1], avoid repeated calls into GetAssemblyDirectory/GetXmlConfigFileName for null returns. check-in: 6058d5f357 user: mistachkin tags: branch-1.0.105
20:43
Also prevent repeated calls into GetAssemblyDirectory and GetXmlConfigFileName when their respective searches are not successful. check-in: 384b2aecc2 user: mistachkin tags: trunk
2017-05-11
15:54
Update version history docs. check-in: 13fa3545f6 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

   689    689         /// <see cref="GetAssemblyDirectory" /> method -OR- null if that method
   690    690         /// has never returned a valid value.
   691    691         /// </summary>
   692    692         private static string cachedAssemblyDirectory;
   693    693   
   694    694         /////////////////////////////////////////////////////////////////////////
   695    695         /// <summary>
          696  +      /// When this field is non-zero, it indicates the
          697  +      /// <see cref="GetAssemblyDirectory" /> method was not able to locate a
          698  +      /// suitable assembly directory.  The
          699  +      /// <see cref="GetCachedAssemblyDirectory" /> method will check this
          700  +      /// field and skips calls into the <see cref="GetAssemblyDirectory" />
          701  +      /// method whenever it is non-zero.
          702  +      /// </summary>
          703  +      private static bool noAssemblyDirectory;
          704  +
          705  +      /////////////////////////////////////////////////////////////////////////
          706  +      /// <summary>
   696    707         /// This is the cached return value from the
   697    708         /// <see cref="GetXmlConfigFileName" /> method -OR- null if that method
   698    709         /// has never returned a valid value.
   699    710         /// </summary>
   700    711         private static string cachedXmlConfigFileName;
          712  +
          713  +      /////////////////////////////////////////////////////////////////////////
          714  +      /// <summary>
          715  +      /// When this field is non-zero, it indicates the
          716  +      /// <see cref="GetXmlConfigFileName" /> method was not able to locate a
          717  +      /// suitable XML configuration file name.  The
          718  +      /// <see cref="GetCachedXmlConfigFileName" /> method will check this
          719  +      /// field and skips calls into the <see cref="GetXmlConfigFileName" />
          720  +      /// method whenever it is non-zero.
          721  +      /// </summary>
          722  +      private static bool noXmlConfigFileName;
   701    723         #endregion
   702    724   
   703    725         /////////////////////////////////////////////////////////////////////////
   704    726         /// <summary>
   705    727         /// For now, this method simply calls the Initialize method.
   706    728         /// </summary>
   707    729         static UnsafeNativeMethods()
................................................................................
   845    867             DebugData.IncrementOtherCount("Method_ResetCachedXmlConfigFileName");
   846    868   #endif
   847    869             #endregion
   848    870   
   849    871             lock (staticSyncRoot)
   850    872             {
   851    873                 cachedXmlConfigFileName = null;
          874  +              noXmlConfigFileName = false;
   852    875             }
   853    876         }
   854    877   
   855    878         /////////////////////////////////////////////////////////////////////////
   856    879         /// <summary>
   857    880         /// Queries and returns the cached XML configuration file name for the
   858    881         /// assembly containing the managed System.Data.SQLite components, if
................................................................................
   872    895   #endif
   873    896             #endregion
   874    897   
   875    898             lock (staticSyncRoot)
   876    899             {
   877    900                 if (cachedXmlConfigFileName != null)
   878    901                     return cachedXmlConfigFileName;
          902  +
          903  +              if (noXmlConfigFileName)
          904  +                  return null;
   879    905             }
   880    906   
   881    907             return GetXmlConfigFileName();
   882    908         }
   883    909   
   884    910         /////////////////////////////////////////////////////////////////////////
   885    911         /// <summary>
................................................................................
   924    950                 lock (staticSyncRoot)
   925    951                 {
   926    952                     cachedXmlConfigFileName = fileName;
   927    953                 }
   928    954   
   929    955                 return fileName;
   930    956             }
          957  +
          958  +          lock (staticSyncRoot)
          959  +          {
          960  +              noXmlConfigFileName = true;
          961  +          }
   931    962   
   932    963             return null;
   933    964         }
   934    965   
   935    966         /////////////////////////////////////////////////////////////////////////
   936    967   
   937    968         /// <summary>
................................................................................
  1592   1623             DebugData.IncrementOtherCount("Method_ResetCachedAssemblyDirectory");
  1593   1624   #endif
  1594   1625             #endregion
  1595   1626   
  1596   1627             lock (staticSyncRoot)
  1597   1628             {
  1598   1629                 cachedAssemblyDirectory = null;
         1630  +              noAssemblyDirectory = false;
  1599   1631             }
  1600   1632         }
  1601   1633   
  1602   1634         /////////////////////////////////////////////////////////////////////////
  1603   1635         /// <summary>
  1604   1636         /// Queries and returns the cached directory for the assembly currently
  1605   1637         /// being executed, if available.  If the cached assembly directory value
................................................................................
  1618   1650   #endif
  1619   1651             #endregion
  1620   1652   
  1621   1653             lock (staticSyncRoot)
  1622   1654             {
  1623   1655                 if (cachedAssemblyDirectory != null)
  1624   1656                     return cachedAssemblyDirectory;
         1657  +
         1658  +              if (noAssemblyDirectory)
         1659  +                  return null;
  1625   1660             }
  1626   1661   
  1627   1662             return GetAssemblyDirectory();
  1628   1663         }
  1629   1664   
  1630   1665         /////////////////////////////////////////////////////////////////////////
  1631   1666         /// <summary>
................................................................................
  1645   1680             #endregion
  1646   1681   
  1647   1682             try
  1648   1683             {
  1649   1684                 Assembly assembly = Assembly.GetExecutingAssembly();
  1650   1685   
  1651   1686                 if (assembly == null)
         1687  +              {
         1688  +                  lock (staticSyncRoot)
         1689  +                  {
         1690  +                      noAssemblyDirectory = true;
         1691  +                  }
         1692  +
  1652   1693                     return null;
         1694  +              }
  1653   1695   
  1654   1696                 string fileName = null;
  1655   1697   
  1656   1698   #if PLATFORM_COMPACTFRAMEWORK
  1657   1699                 AssemblyName assemblyName = assembly.GetName();
  1658   1700   
  1659   1701                 if (assemblyName == null)
         1702  +              {
         1703  +                  lock (staticSyncRoot)
         1704  +                  {
         1705  +                      noAssemblyDirectory = true;
         1706  +                  }
         1707  +
  1660   1708                     return null;
         1709  +              }
  1661   1710   
  1662   1711                 fileName = assemblyName.CodeBase;
  1663   1712   #else
  1664   1713                 if (!CheckAssemblyCodeBase(assembly, ref fileName))
  1665   1714                     fileName = assembly.Location;
  1666   1715   #endif
  1667   1716   
  1668   1717                 if (String.IsNullOrEmpty(fileName))
         1718  +              {
         1719  +                  lock (staticSyncRoot)
         1720  +                  {
         1721  +                      noAssemblyDirectory = true;
         1722  +                  }
         1723  +
  1669   1724                     return null;
         1725  +              }
  1670   1726   
  1671   1727                 string directory = Path.GetDirectoryName(fileName);
  1672   1728   
  1673   1729                 if (String.IsNullOrEmpty(directory))
         1730  +              {
         1731  +                  lock (staticSyncRoot)
         1732  +                  {
         1733  +                      noAssemblyDirectory = true;
         1734  +                  }
         1735  +
  1674   1736                     return null;
         1737  +              }
  1675   1738   
  1676   1739                 lock (staticSyncRoot)
  1677   1740                 {
  1678   1741                     cachedAssemblyDirectory = directory;
  1679   1742                 }
  1680   1743   
  1681   1744                 return directory;
................................................................................
  1696   1759                 }
  1697   1760                 catch
  1698   1761                 {
  1699   1762                     // do nothing.
  1700   1763                 }
  1701   1764   #endif
  1702   1765             }
         1766  +
         1767  +          lock (staticSyncRoot)
         1768  +          {
         1769  +              noAssemblyDirectory = true;
         1770  +          }
  1703   1771   
  1704   1772             return null;
  1705   1773         }
  1706   1774         #endregion
  1707   1775   
  1708   1776         /////////////////////////////////////////////////////////////////////////
  1709   1777