Unverified Commit 9dc52fc1 authored by Oleh's avatar Oleh

remove locks

parent 12550f53
...@@ -106,12 +106,10 @@ Json::Value signByHashImpl(const string &hash, int status) { ...@@ -106,12 +106,10 @@ Json::Value signByHashImpl(const string &hash, int status) {
} }
Json::Value CSRManagerServer::getUnsignedCSRs() { Json::Value CSRManagerServer::getUnsignedCSRs() {
LOCK(m)
return getUnsignedCSRsImpl(); return getUnsignedCSRsImpl();
} }
Json::Value CSRManagerServer::signByHash(const string &hash, int status) { Json::Value CSRManagerServer::signByHash(const string &hash, int status) {
LOCK(m)
return signByHashImpl(hash, status); return signByHashImpl(hash, status);
} }
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "common.h" #include "common.h"
#include <mutex> // For std::unique_lock
#include <shared_mutex> #include <shared_mutex>
using namespace std; using namespace std;
...@@ -78,9 +77,5 @@ public: ...@@ -78,9 +77,5 @@ public:
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \ #define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
catch (exception &__e) {spdlog::error(__e.what()); _RESULT_["status"] = 1; _RESULT_["errorMessage"] = __e.what();} catch (exception &__e) {spdlog::error(__e.what()); _RESULT_["status"] = 1; _RESULT_["errorMessage"] = __e.what();}
#define READ_LOCK(__M__) ReadLock __rlock(__M__);
#define WRITE_LOCK(__M__) WriteLock __wlock(__M__);
#define LOCK(__M__) lock_guard<recursive_mutex> lock(__M__);
#endif #endif
...@@ -153,13 +153,11 @@ Json::Value getCertificateImpl(const string &hash) { ...@@ -153,13 +153,11 @@ Json::Value getCertificateImpl(const string &hash) {
Json::Value SGXRegistrationServer::SignCertificate(const string &csr) { Json::Value SGXRegistrationServer::SignCertificate(const string &csr) {
spdlog::info(__FUNCTION__); spdlog::info(__FUNCTION__);
LOCK(m)
return signCertificateImpl(csr, autoSign); return signCertificateImpl(csr, autoSign);
} }
Json::Value SGXRegistrationServer::GetCertificate(const string &hash) { Json::Value SGXRegistrationServer::GetCertificate(const string &hash) {
spdlog::info(__FUNCTION__); spdlog::info(__FUNCTION__);
LOCK(m)
return getCertificateImpl(hash); return getCertificateImpl(hash);
} }
......
...@@ -674,17 +674,14 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) { ...@@ -674,17 +674,14 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
} }
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) { Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
WRITE_LOCK(m)
return generateDKGPolyImpl(_polyName, _t); return generateDKGPolyImpl(_polyName, _t);
} }
Json::Value SGXWalletServer::getVerificationVector(const string &_polynomeName, int _t, int _n) { Json::Value SGXWalletServer::getVerificationVector(const string &_polynomeName, int _t, int _n) {
WRITE_LOCK(m)
return getVerificationVectorImpl(_polynomeName, _t, _n); return getVerificationVectorImpl(_polynomeName, _t, _n);
} }
Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json::Value &_publicKeys, int t, int n) { Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json::Value &_publicKeys, int t, int n) {
WRITE_LOCK(m)
return getSecretShareImpl(_polyName, _publicKeys, t, n); return getSecretShareImpl(_polyName, _publicKeys, t, n);
} }
...@@ -692,39 +689,32 @@ Json::Value ...@@ -692,39 +689,32 @@ Json::Value
SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare, SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare,
int t, int t,
int n, int index) { int n, int index) {
WRITE_LOCK(m)
return dkgVerificationImpl(_publicShares, ethKeyName, SecretShare, t, n, index); return dkgVerificationImpl(_publicShares, ethKeyName, SecretShare, t, n, index);
} }
Json::Value Json::Value
SGXWalletServer::createBLSPrivateKey(const string &blsKeyName, const string &ethKeyName, const string &polyName, SGXWalletServer::createBLSPrivateKey(const string &blsKeyName, const string &ethKeyName, const string &polyName,
const string &SecretShare, int t, int n) { const string &SecretShare, int t, int n) {
WRITE_LOCK(m)
return createBLSPrivateKeyImpl(blsKeyName, ethKeyName, polyName, SecretShare, t, n); return createBLSPrivateKeyImpl(blsKeyName, ethKeyName, polyName, SecretShare, t, n);
} }
Json::Value SGXWalletServer::getBLSPublicKeyShare(const string &blsKeyName) { Json::Value SGXWalletServer::getBLSPublicKeyShare(const string &blsKeyName) {
READ_LOCK(m)
return getBLSPublicKeyShareImpl(blsKeyName); return getBLSPublicKeyShareImpl(blsKeyName);
} }
Json::Value SGXWalletServer::generateECDSAKey() { Json::Value SGXWalletServer::generateECDSAKey() {
WRITE_LOCK(m)
return generateECDSAKeyImpl(); return generateECDSAKeyImpl();
} }
Json::Value SGXWalletServer::renameECDSAKey(const string &_keyName, const string &_tmpKeyName) { Json::Value SGXWalletServer::renameECDSAKey(const string &_keyName, const string &_tmpKeyName) {
WRITE_LOCK(m)
return renameECDSAKeyImpl(_keyName, _tmpKeyName); return renameECDSAKeyImpl(_keyName, _tmpKeyName);
} }
Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) { Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
READ_LOCK(m)
return getPublicECDSAKeyImpl(_keyName); return getPublicECDSAKeyImpl(_keyName);
} }
Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyShareName, const string &_messageHash) { Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyShareName, const string &_messageHash) {
READ_LOCK(m)
spdlog::debug("MessageHash first {}", _messageHash); spdlog::debug("MessageHash first {}", _messageHash);
return ecdsaSignMessageHashImpl(_base, _keyShareName, _messageHash); return ecdsaSignMessageHashImpl(_base, _keyShareName, _messageHash);
} }
...@@ -732,48 +722,39 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS ...@@ -732,48 +722,39 @@ Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyS
Json::Value Json::Value
SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keyShareName, int _t, int _n, SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keyShareName, int _t, int _n,
int index) { int index) {
WRITE_LOCK(m)
return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index); return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index);
} }
Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n, Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n,
int _signerIndex) { int _signerIndex) {
READ_LOCK(m)
return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n, _signerIndex); return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n, _signerIndex);
} }
Json::Value SGXWalletServer::importECDSAKey(const string &_key, const string &_keyName) { Json::Value SGXWalletServer::importECDSAKey(const string &_key, const string &_keyName) {
WRITE_LOCK(m)
return importECDSAKeyImpl(_key, _keyName); return importECDSAKeyImpl(_key, _keyName);
} }
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) { Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) {
WRITE_LOCK(m)
return complaintResponseImpl(polyName, ind); return complaintResponseImpl(polyName, ind);
} }
Json::Value SGXWalletServer::multG2(const string &x) { Json::Value SGXWalletServer::multG2(const string &x) {
WRITE_LOCK(m)
return multG2Impl(x); return multG2Impl(x);
} }
Json::Value SGXWalletServer::isPolyExists(const string &polyName) { Json::Value SGXWalletServer::isPolyExists(const string &polyName) {
WRITE_LOCK(m)
return isPolyExistsImpl(polyName); return isPolyExistsImpl(polyName);
} }
Json::Value SGXWalletServer::getServerStatus() { Json::Value SGXWalletServer::getServerStatus() {
READ_LOCK(m)
return getServerStatusImpl(); return getServerStatusImpl();
} }
Json::Value SGXWalletServer::getServerVersion() { Json::Value SGXWalletServer::getServerVersion() {
READ_LOCK(m)
return getServerVersionImpl(); return getServerVersionImpl();
} }
Json::Value SGXWalletServer::deleteBlsKey(const std::string& name) { Json::Value SGXWalletServer::deleteBlsKey(const std::string& name) {
READ_LOCK(m)
return deleteBlsKeyImpl(name); return deleteBlsKeyImpl(name);
} }
......
...@@ -24,13 +24,8 @@ ...@@ -24,13 +24,8 @@
#ifndef SGXWALLET_SGXWALLETSERVER_HPP #ifndef SGXWALLET_SGXWALLETSERVER_HPP
#define SGXWALLET_SGXWALLETSERVER_HPP #define SGXWALLET_SGXWALLETSERVER_HPP
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/shared_mutex.hpp>
typedef boost::shared_mutex Lock;
typedef boost::unique_lock< Lock > WriteLock;
typedef boost::shared_lock< Lock > ReadLock;
#include <jsonrpccpp/server/connectors/httpserver.h> #include <jsonrpccpp/server/connectors/httpserver.h>
#include <mutex> #include <mutex>
#include "abstractstubserver.h" #include "abstractstubserver.h"
...@@ -42,8 +37,6 @@ using namespace std; ...@@ -42,8 +37,6 @@ using namespace std;
#define TOSTRING(x) STRINGIFY(x) #define TOSTRING(x) STRINGIFY(x)
class SGXWalletServer : public AbstractStubServer { class SGXWalletServer : public AbstractStubServer {
Lock m;
static shared_ptr<SGXWalletServer> server; static shared_ptr<SGXWalletServer> server;
static shared_ptr<HttpServer> httpServer; static shared_ptr<HttpServer> httpServer;
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment