diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-11 15:02:26 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-11 15:02:26 -0700 |
commit | cd005341c5b6a81f6b23129041828c31d432c5a9 (patch) | |
tree | 459ddba565b1a1ef3c37ab00c175be7483374f33 /controller | |
parent | c1a53a26536d2635118262f5f719795b2e70e5fa (diff) | |
download | infinitytier-cd005341c5b6a81f6b23129041828c31d432c5a9.tar.gz infinitytier-cd005341c5b6a81f6b23129041828c31d432c5a9.zip |
Extra statement to clean up Members -- cascade did not seem to work, possibly due to dual key.
Diffstat (limited to 'controller')
-rw-r--r-- | controller/SqliteNetworkController.cpp | 9 | ||||
-rw-r--r-- | controller/SqliteNetworkController.hpp | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp index 7098a027..f7d95666 100644 --- a/controller/SqliteNetworkController.cpp +++ b/controller/SqliteNetworkController.cpp @@ -203,6 +203,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) : ||(sqlite3_prepare_v2(_db,"UPDATE Member SET authorized = ?,memberRevision = (SELECT memberRevisionCounter FROM Network WHERE id = ?) WHERE rowid = ?",-1,&_sUpdateMemberAuthorized,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"UPDATE Member SET activeBridge = ?,memberRevision = (SELECT memberRevisionCounter FROM Network WHERE id = ?) WHERE rowid = ?",-1,&_sUpdateMemberActiveBridge,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"DELETE FROM Member WHERE networkId = ? AND nodeId = ?",-1,&_sDeleteMember,(const char **)0) != SQLITE_OK) + ||(sqlite3_prepare_v2(_db,"DELETE FROM Member WHERE networkId = ?",-1,&_sDeleteAllNetworkMembers,(const char **)0) != SQLITE_OK) /* Gateway */ ||(sqlite3_prepare_v2(_db,"SELECT \"ip\",ipVersion,metric FROM Gateway WHERE networkId = ? ORDER BY metric ASC",-1,&_sGetGateways,(const char **)0) != SQLITE_OK) @@ -287,6 +288,7 @@ SqliteNetworkController::~SqliteNetworkController() sqlite3_finalize(_sUpdateMemberAuthorized); sqlite3_finalize(_sUpdateMemberActiveBridge); sqlite3_finalize(_sDeleteMember); + sqlite3_finalize(_sDeleteAllNetworkMembers); sqlite3_finalize(_sDeleteNetwork); sqlite3_finalize(_sGetGateways); sqlite3_finalize(_sDeleteGateways); @@ -932,7 +934,12 @@ unsigned int SqliteNetworkController::handleControlPlaneHttpDELETE( sqlite3_reset(_sDeleteNetwork); sqlite3_bind_text(_sDeleteNetwork,1,nwids,16,SQLITE_STATIC); - return ((sqlite3_step(_sDeleteNetwork) == SQLITE_DONE) ? 200 : 500); + if (sqlite3_step(_sDeleteNetwork) == SQLITE_DONE) { + sqlite3_reset(_sDeleteAllNetworkMembers); + sqlite3_bind_text(_sDeleteAllNetworkMembers,1,nwids,16,SQLITE_STATIC); + sqlite3_step(_sDeleteAllNetworkMembers); + return 200; + } else return 500; } } // else 404 diff --git a/controller/SqliteNetworkController.hpp b/controller/SqliteNetworkController.hpp index 5d995379..23e16c4b 100644 --- a/controller/SqliteNetworkController.hpp +++ b/controller/SqliteNetworkController.hpp @@ -143,6 +143,7 @@ private: sqlite3_stmt *_sUpdateMemberAuthorized; sqlite3_stmt *_sUpdateMemberActiveBridge; sqlite3_stmt *_sDeleteMember; + sqlite3_stmt *_sDeleteAllNetworkMembers; sqlite3_stmt *_sDeleteNetwork; sqlite3_stmt *_sGetGateways; sqlite3_stmt *_sDeleteGateways; |