From e2cc7213a3a1b64f63750aee37abc8508101d68d Mon Sep 17 00:00:00 2001 From: joss17 Date: Thu, 14 Jan 2010 01:33:56 +0000 Subject: [PATCH] Ad a friend right upon connection when necessary. Removed two core mutex to do that, it might be dangerous, we will see git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2037 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authssl.cc | 12 ++++++------ libretroshare/src/pqi/p3connmgr.cc | 25 +++++++++++++++---------- libretroshare/src/pqi/pqihandler.cc | 2 +- libretroshare/src/pqi/pqipersongrp.cc | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/libretroshare/src/pqi/authssl.cc b/libretroshare/src/pqi/authssl.cc index dc16698fb..e0d17fc55 100644 --- a/libretroshare/src/pqi/authssl.cc +++ b/libretroshare/src/pqi/authssl.cc @@ -2185,10 +2185,10 @@ int AuthSSL::VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx) //sslcert *cert = NULL; std::string certId; getX509id(X509_STORE_CTX_get_current_cert(ctx), certId); - if (!mConnMgr->isFriend(certId)) { - //we've got a new ssl id - preverify_ok = false; - } +// if (!mConnMgr->isFriend(certId)) { +// //we've got a new ssl id +// preverify_ok = false; +// } //is the connection was initiated by us, then it was for a specific peer id wich is stored is in the context //check that the peerid in the context is the same as the cert one @@ -2211,13 +2211,13 @@ int AuthSSL::VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx) } } - //just to be sure + //Add, even if it might already be added mConnMgr->addFriend(certId, getX509CNString(X509_STORE_CTX_get_current_cert(ctx)->cert_info->issuer)); //set location mConnMgr->setLocation(certId, getX509LocString(X509_STORE_CTX_get_current_cert(ctx)->cert_info->subject)); - //Cgheck if peer isn't already connected + //Check if peer isn't already connected peerConnectState detail; if (mConnMgr->getFriendNetStatus(certId, detail)) { if (detail.state & RS_PEER_CONNECTED && detail.connecttype & RS_NET_CONN_TUNNEL) { diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index fb9706aef..6793d8cf7 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -2005,23 +2005,24 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod /* (1) already exists */ return false; } - /* so four possibilities - * (1) already exists as friend -> do nothing. - * (2) is in others list -> move over. - * (3) is non-existant -> create new one. - */ + /* so four possibilities + * (1) already exists as friend -> do nothing. + * (2) is in others list -> move over. + * (3) is non-existant -> create new one. + */ #ifdef CONN_DEBUG - std::cerr << "p3ConnectMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl; + std::cerr << "p3ConnectMgr::addFriend() " << id << "; gpg_id : " << gpg_id << std::endl; #endif #ifdef CONN_DEBUG - std::cerr << "p3ConnectMgr::addFriend() removing dummy friend" << std::endl; + std::cerr << "p3ConnectMgr::addFriend() removing dummy friend" << std::endl; #endif - //remove any dummy friend because we just add a real ssl friend - removeFriend("dummy"+ gpg_id); + //remove any dummy friend because we just add a real ssl friend + removeFriend("dummy"+ gpg_id); - RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ + { + RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ std::map::iterator it; @@ -2114,6 +2115,10 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ + } + //usefull because we might add a friend by receiving an ssl connection, so we want the monitors to act right now + tickMonitors(); + return true; } diff --git a/libretroshare/src/pqi/pqihandler.cc b/libretroshare/src/pqi/pqihandler.cc index d917e122b..10fccde34 100644 --- a/libretroshare/src/pqi/pqihandler.cc +++ b/libretroshare/src/pqi/pqihandler.cc @@ -129,7 +129,7 @@ int pqihandler::status() bool pqihandler::AddSearchModule(SearchModule *mod) { - RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ + //RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ This might be dangerous, but usefull for accepting new frinds right upon connection // if peerid used -> error. std::map::iterator it; if (mod->peerid != mod->pqi->PeerId()) diff --git a/libretroshare/src/pqi/pqipersongrp.cc b/libretroshare/src/pqi/pqipersongrp.cc index cb9ddf599..5d876b029 100644 --- a/libretroshare/src/pqi/pqipersongrp.cc +++ b/libretroshare/src/pqi/pqipersongrp.cc @@ -314,7 +314,7 @@ int pqipersongrp::addPeer(std::string id) #endif SearchModule *sm = NULL; - { RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ + { //RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ This might be dangerous, but usefull for accepting new frinds right upon connection std::map::iterator it; it = mods.find(id); if (it != mods.end())