summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-03-26 15:20:22 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2013-03-26 15:20:22 +0100
commit1e55712f5ed3d32c77d53b26d7c024e6f9d6d52f (patch)
tree30da5364b960f85df3b20b63284a9b59eca9ca93 /storage/connect
parent0df7a43e2290fe96a5c211c89c2e2b4f4ba96c2c (diff)
downloadmariadb-git-1e55712f5ed3d32c77d53b26d7c024e6f9d6d52f.tar.gz
- On Linux, closing an INI table removes it from the inihandl cache
modified: storage/connect/inihandl.c storage/connect/osutil.h storage/connect/tabsys.cpp - Clean. Remove some unused functions modified: storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/inihandl.c53
-rw-r--r--storage/connect/osutil.h2
-rw-r--r--storage/connect/plgdbsem.h6
-rw-r--r--storage/connect/plgdbutl.cpp10
-rw-r--r--storage/connect/tabsys.cpp4
5 files changed, 66 insertions, 9 deletions
diff --git a/storage/connect/inihandl.c b/storage/connect/inihandl.c
index aafa202d040..560636c37e1 100644
--- a/storage/connect/inihandl.c
+++ b/storage/connect/inihandl.c
@@ -99,10 +99,10 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL};
#define PROFILE_MAX_LINE_LEN 1024
/* Wine profile name in $HOME directory; must begin with slash */
-static const char PROFILE_WineIniName[] = "/.winerc";
+//static const char PROFILE_WineIniName[] = "/.winerc";
/* Wine profile: the profile file being used */
-static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = "";
+//static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = "";
/* Check for comments in profile */
#define IS_ENTRY_COMMENT(str) ((str)[0] == ';')
@@ -561,6 +561,55 @@ static BOOL PROFILE_Open(LPCSTR filename)
/***********************************************************************
+ * PROFILE_Close
+ *
+ * Flush the named profile to disk and remove it from the cache.
+ ***********************************************************************/
+static void PROFILE_Close(LPCSTR filename)
+{
+ int i;
+ BOOL close = FALSE;
+ struct stat buf;
+ PROFILE *tempProfile;
+
+ if (trace > 1)
+ htrc("PROFILE_Close: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES);
+
+ /* Check for a match */
+ for (i = 0; i < N_CACHED_PROFILES; i++) {
+ if (trace > 1)
+ htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i);
+
+ if (MRUProfile[i]->filename && !strcmp(filename, MRUProfile[i]->filename)) {
+ if (i) {
+ /* Make the profile to close current */
+ tempProfile = MRUProfile[i];
+ MRUProfile[i] = MRUProfile[0];
+ MRUProfile[0] = tempProfile;
+ CurProfile=tempProfile;
+ } // endif i
+
+ if (trace > 1) {
+ if (!stat(CurProfile->filename, &buf) && CurProfile->mtime == buf.st_mtime)
+ htrc("(%s): already opened (mru=%d)\n", filename, i);
+ else
+ htrc("(%s): already opened, needs refreshing (mru=%d)\n", filename, i);
+
+ } // endif trace
+
+ close = TRUE;
+ break;
+ } // endif filename
+
+ } // endfor i
+
+ if (close)
+ PROFILE_ReleaseFile();
+
+} // end of PROFILE_Close
+
+
+/***********************************************************************
* PROFILE_DeleteSection
*
* Delete a section from a profile tree.
diff --git a/storage/connect/osutil.h b/storage/connect/osutil.h
index bbc4f3d2def..440373dd7a1 100644
--- a/storage/connect/osutil.h
+++ b/storage/connect/osutil.h
@@ -32,6 +32,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength);
BOOL MessageBeep(uint);
unsigned long _filelength(int fd);
+void PROFILE_Close(LPCSTR filename);
+
int GetPrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h
index f77dda67984..611b0067e18 100644
--- a/storage/connect/plgdbsem.h
+++ b/storage/connect/plgdbsem.h
@@ -559,9 +559,9 @@ DllExport PDBUSER PlgGetUser(PGLOBAL g);
DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true);
DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int);
DllExport void PlgDBfree(MBLOCK&);
-DllExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
-DllExport int GetIniSize(char *, char *, char *, char *);
-DllExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
+//lExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
+//lExport int GetIniSize(char *, char *, char *, char *);
+//lExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
DllExport void NewPointer(PTABS, void *, void *);
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index ef6e3d5f6c6..6d1e502945b 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -411,12 +411,13 @@ char *PlgGetDataPath(PGLOBAL g)
{
PCATLG cat = PlgGetCatalog(g, false);
- if (!cat)
- return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
+//if (!cat)
+// return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
- return cat->GetDataPath();
+ return (cat) ? cat->GetDataPath() : NULL;
} // end of PlgGetDataPath
+#if 0
/***********************************************************************/
/* PlgGetXdbPath: sets the fully qualified file name of a database */
/* description file in lgn and the new datapath in dp. */
@@ -513,6 +514,7 @@ bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath,
return false;
} // end of PlgSetXdbPath
+#endif // 0
/***********************************************************************/
/* Extract from a path name the required component. */
@@ -1040,6 +1042,7 @@ void PlugCleanup(PGLOBAL g, bool dofree)
} // end of PlugCleanup
+#if 0
/***********************************************************************/
/* That stupid Windows 98 does not provide this function. */
/***********************************************************************/
@@ -1116,6 +1119,7 @@ DllExport PSZ GetIniString(PGLOBAL g, void *mp, LPCSTR sec, LPCSTR key,
return p;
} // end of GetIniString
+#endif // 0
/***********************************************************************/
/* GetAmName: return the name correponding to an AM code. */
diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp
index 4304f2421a6..9f933e4e2b8 100644
--- a/storage/connect/tabsys.cpp
+++ b/storage/connect/tabsys.cpp
@@ -388,7 +388,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
void TDBINI::CloseDB(PGLOBAL g)
{
- // Nothing to do
+#if !defined(WIN32)
+ PROFILE_Close(Ifile);
+#endif // !WIN32
} // end of CloseDB
// ------------------------ INICOL functions ----------------------------