예제 #1
0
   restSessionInfo* _pmdController::newSessionInfo( const string & userName,
                                                    UINT32 localIP )
   {
      restSessionInfo *newSession = SDB_OSS_NEW restSessionInfo ;
      if( !newSession )
      {
         PD_LOG( PDERROR, "Alloc rest session info failed" ) ;
         goto error ;
      }

      _ctrlLatch.get() ;
      newSession->_attr._sessionID = ossPack32To64( localIP, _sequence++ ) ;
      ossStrncpy( newSession->_attr._userName, userName.c_str(),
                  SESSION_USER_NAME_LEN ) ;
      _mapSessions[ _makeID( newSession ) ] = newSession ;
      _add2UserMap( userName, newSession ) ;
      newSession->_inNum.inc() ;
      _ctrlLatch.release() ;
      newSession->lock() ;

   done:
      return newSession ;
   error:
      goto done ;
   }
예제 #2
0
   // The caller is responsible to free memory
   restSessionInfo* _pmdController::newSessionInfo( const string & userName,
                                                    UINT32 localIP )
   {
      // memory will be freed in releaseSessionInfo ( manual release )and
      // _checkSession ( timeout release )
      restSessionInfo *newSession = SDB_OSS_NEW restSessionInfo ;
      if( !newSession )
      {
         PD_LOG( PDERROR, "Alloc rest session info failed" ) ;
         goto error ;
      }

      // get lock
      _ctrlLatch.get() ;
      newSession->_attr._sessionID = ossPack32To64( localIP, _sequence++ ) ;
      ossStrncpy( newSession->_attr._userName, userName.c_str(),
                  SESSION_USER_NAME_LEN ) ;
      // add to session map
      _mapSessions[ _makeID( newSession ) ] = newSession ;
      // add to user session map
      _add2UserMap( userName, newSession ) ;
      // attach session
      newSession->_inNum.inc() ;
      // release lock
      _ctrlLatch.release() ;
      // The session will be locked once it's created, and the caller will
      // start working on the session. Once the work is done, the session will
      // be unlocked ( detached or destroyed )
      newSession->lock() ;

   done:
      return newSession ;
   error:
      goto done ;
   }