Commit 64b4cfba authored by jan.koester's avatar jan.koester
Browse files

fixed locking

parent 740693f7
Loading
Loading
Loading
Loading
Loading
+0 −1
Changes for src/api.cpp: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -435,7 +435,6 @@ namespace authdb {
        }

        Api(AuthBackend &admin,class uuid did, libhttppp::HttpRequest* curreq, const int tid, ULONG_PTR args) : _Backend(admin), _Did(did){
             std::lock_guard<std::mutex> lock(AuthClientLock);
            _SessionData=nullptr;

            libhttppp::HttpResponse rep;
+2 −2
Changes for src/authdb.cpp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -59,9 +59,7 @@
namespace authdb {

    class Client     AuthClient;
    std::mutex       AuthClientLock;
    class Session  AuthSession;
    std::mutex       AuthSessionLock;

    std::mutex g_wizzard;

@@ -265,6 +263,7 @@ namespace authdb {
                }

                if(apidb){
                    apidb->lock();
                    try{
                        ApiController(*apidb,did,curreq,tid,args);
                    }catch(AuthBackendError &e){
@@ -273,6 +272,7 @@ namespace authdb {
                        rep.setContentType("text/html");
                        rep.send(curreq,e.what(),strlen(e.what()));
                    }
                    apidb->unlock();
                }else{
                    libhttppp::HttpResponse rep;
                    rep.setState(HTTP404);
+3 −2
Changes for src/backends/file.cpp: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ namespace authdb {
};

authdb::File::File(const char* path,size_t version,const char *domain){
    std::lock_guard<std::mutex> lock( _fileMutex);
    if( (_FileDes=::open(path,O_RDWR)) <0){

        _FileDes=::open(path,O_CREAT|O_RDWR,0660);
@@ -109,7 +110,7 @@ void authdb::File::write(const unsigned char* dest, size_t destsize){
}

void authdb::File::lock(){
    _fileMutex.lock();
   std::lock_guard<std::mutex> lock( _fileMutex);
#ifndef Windows
    for(;;){
        mode_t m = umask( 0 );
@@ -138,12 +139,12 @@ void authdb::File::lock(){
}

void authdb::File::unlock(){
    std::lock_guard<std::mutex> lock( _fileMutex);
#ifndef Windows
    flock(_LockDes,LOCK_UN);
    close(_LockDes);
    remove(_lockFile.c_str());
#endif
    _fileMutex.unlock();
}

void authdb::File::setPos(size_t pos){