[cpp-sp COMMIT] in /branches/REL_2: odbc-store/odbc-store.cpp shibsp/impl/StorageServiceSessionCache.cpp
noreply at shibboleth.net
noreply at shibboleth.net
Mon Oct 8 23:07:22 EDT 2012
Author: scantor
Date: Mon Oct 8 23:07:22 2012
New Revision: 3777
URL: http://svn.shibboleth.net/view/cpp-sp?rev=3777&view=rev
Log:
https://issues.shibboleth.net/jira/browse/SSPCPP-507
Modified:
branches/REL_2/odbc-store/odbc-store.cpp
branches/REL_2/shibsp/impl/StorageServiceSessionCache.cpp
Modified: branches/REL_2/odbc-store/odbc-store.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/odbc-store/odbc-store.cpp?rev=3777&r1=3776&r2=3777&view=diff
==============================================================================
--- branches/REL_2/odbc-store/odbc-store.cpp (original)
+++ branches/REL_2/odbc-store/odbc-store.cpp Mon Oct 8 23:07:22 2012
@@ -63,7 +63,7 @@
using namespace std;
#define PLUGIN_VER_MAJOR 1
-#define PLUGIN_VER_MINOR 0
+#define PLUGIN_VER_MINOR 1
#define LONGDATA_BUFLEN 16384
@@ -84,7 +84,7 @@
context varchar(255) not null,
id varchar(255) not null,
expires datetime not null,
- version smallint not null,
+ version int not null,
value varchar(255) not null,
PRIMARY KEY (context, id)
)
@@ -93,7 +93,7 @@
context varchar(255) not null,
id varchar(255) not null,
expires datetime not null,
- version smallint not null,
+ version int not null,
value text not null,
PRIMARY KEY (context, id)
)
@@ -207,6 +207,7 @@
SQLHENV m_henv;
string m_connstring;
long m_isolation;
+ bool m_wideVersion;
vector<SQLINTEGER> m_retries;
};
@@ -271,7 +272,7 @@
ODBCStorageService::ODBCStorageService(const DOMElement* e) : m_log(Category::getInstance("XMLTooling.StorageService")),
m_caps(XMLHelper::getAttrInt(e, 255, contextSize), XMLHelper::getAttrInt(e, 255, keySize), XMLHelper::getAttrInt(e, 255, stringSize)),
m_cleanupInterval(XMLHelper::getAttrInt(e, 900, cleanupInterval)),
- cleanup_thread(nullptr), shutdown(false), m_henv(SQL_NULL_HENV), m_isolation(SQL_TXN_SERIALIZABLE)
+ cleanup_thread(nullptr), shutdown(false), m_henv(SQL_NULL_HENV), m_isolation(SQL_TXN_SERIALIZABLE), m_wideVersion(false)
{
#ifdef _DEBUG
xmltooling::NDC ndc("ODBCStorageService");
@@ -321,6 +322,11 @@
m_log.crit("unknown database version: %d.%d", v.first, v.second);
throw XMLToolingException("Unknown database version for ODBC StorageService.");
}
+
+ if (v.first > 1 || v.second > 0) {
+ m_log.info("using 32-bit int type for version fields in tables");
+ m_wideVersion = true;
+ }
// Load any retry errors to check.
e = XMLHelper::getNextSiblingElement(e, RetryOnError);
@@ -542,20 +548,30 @@
}
SQLSMALLINT ver;
+ SQLINTEGER widever;
SQL_TIMESTAMP_STRUCT expiration;
- SQLBindCol(stmt, 1, SQL_C_SSHORT, &ver, 0, nullptr);
+ if (m_wideVersion)
+ SQLBindCol(stmt, 1, SQL_C_SLONG, &widever, 0, nullptr);
+ else
+ SQLBindCol(stmt, 1, SQL_C_SSHORT, &ver, 0, nullptr);
if (pexpiration)
SQLBindCol(stmt, 2, SQL_C_TYPE_TIMESTAMP, &expiration, 0, nullptr);
- if ((sr = SQLFetch(stmt)) == SQL_NO_DATA)
+ if ((sr = SQLFetch(stmt)) == SQL_NO_DATA) {
+ if (m_log.isDebugEnabled())
+ m_log.debug("search returned no data (t=%s, c=%s, k=%s)", table, context, key);
return 0;
+ }
if (pexpiration)
*pexpiration = timeFromTimestamp(expiration);
- if (version == ver)
+ if (version == (m_wideVersion ? widever : ver)) {
+ if (m_log.isDebugEnabled())
+ m_log.debug("versioned search detected no change (t=%s, c=%s, k=%s)", table, context, key);
return version; // nothing's changed, so just echo back the version
+ }
if (pvalue) {
SQLLEN len;
@@ -570,7 +586,7 @@
}
}
- return ver;
+ return (m_wideVersion ? widever : ver);
}
int ODBCStorageService::updateRow(const char *table, const char* context, const char* key, const char* value, time_t expiration, int version)
@@ -608,14 +624,22 @@
}
SQLSMALLINT ver;
- SQLBindCol(stmt, 1, SQL_C_SSHORT, &ver, 0, nullptr);
+ SQLINTEGER widever;
+ if (m_wideVersion)
+ SQLBindCol(stmt, 1, SQL_C_SLONG, &widever, 0, nullptr);
+ else
+ SQLBindCol(stmt, 1, SQL_C_SSHORT, &ver, 0, nullptr);
if ((sr = SQLFetch(stmt)) == SQL_NO_DATA) {
return 0;
}
// Check version?
- if (version > 0 && version != ver) {
+ if (version > 0 && version != (m_wideVersion ? widever : ver)) {
return -1;
+ }
+ else if ((m_wideVersion && widever == INT_MAX) || (!m_wideVersion && ver == 32767)) {
+ m_log.error("record version overflow (t=%s, c=%s, k=%s)", table, context, key);
+ throw IOException("Version overflow, record in ODBC StorageService could not be updated.");
}
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -651,11 +675,11 @@
else
sr = SQLBindParam(stmt, 1, SQL_C_CHAR, SQL_VARCHAR, 255, 0, const_cast<char*>(value), &b_ind);
if (!SQL_SUCCEEDED(sr)) {
- m_log.error("SQLBindParam failed (context = %s)", context);
[... 206 lines stripped ...]
More information about the commits
mailing list