You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ak...@apache.org on 2010/05/12 19:58:35 UTC

svn commit: r943599 - in /trafficserver/traffic/branches/UserFiber: Makefile include/UF.H include/UFConnectionPool.H src/Makefile src/UF.C

Author: akundu
Date: Wed May 12 17:58:35 2010
New Revision: 943599

URL: http://svn.apache.org/viewvc?rev=943599&view=rev
Log:
- added the makefile in the src directory
- integrated the connectionpool into uf


Added:
    trafficserver/traffic/branches/UserFiber/src/Makefile
Modified:
    trafficserver/traffic/branches/UserFiber/Makefile
    trafficserver/traffic/branches/UserFiber/include/UF.H
    trafficserver/traffic/branches/UserFiber/include/UFConnectionPool.H
    trafficserver/traffic/branches/UserFiber/src/UF.C

Modified: trafficserver/traffic/branches/UserFiber/Makefile
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/UserFiber/Makefile?rev=943599&r1=943598&r2=943599&view=diff
==============================================================================
--- trafficserver/traffic/branches/UserFiber/Makefile (original)
+++ trafficserver/traffic/branches/UserFiber/Makefile Wed May 12 17:58:35 2010
@@ -1,10 +1,10 @@
 CPP=c++
-BUILD_FLAGS=-g -O3 -Wall -DPIPE_NOT_EFD -Wno-deprecated -m32
+BUILD_FLAGS=-g -O3 -Wall -DPIPE_NOT_EFD -Wno-deprecated
 ARCH=x86-64
 
 all:	ufHTTPServer
 
-ufHTTPServer.o:	ufHTTPServer.C
+ufHTTPServer.o:	ufHTTPServer.C lib/libUF.a
 	$(CPP) $(BUILD_FLAGS) -c -I./include -o ufHTTPServer.o ufHTTPServer.C -march=$(ARCH)
 
 ufHTTPServer:	ufHTTPServer.o

Modified: trafficserver/traffic/branches/UserFiber/include/UF.H
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/UserFiber/include/UF.H?rev=943599&r1=943598&r2=943599&view=diff
==============================================================================
--- trafficserver/traffic/branches/UserFiber/include/UF.H (original)
+++ trafficserver/traffic/branches/UserFiber/include/UF.H Wed May 12 17:58:35 2010
@@ -13,7 +13,6 @@
 #include <ucontext.h>
 #include <pthread.h>
 
-
 using namespace std;
 namespace std { using namespace __gnu_cxx; }
 
@@ -135,6 +134,8 @@ protected:
 typedef std::multimap<unsigned long long int, UF*> MapTimeUF;
 //typedef std::map<pthread_t,UFScheduler*> ThreadUFSchedulerMap;
 typedef hash_map<pthread_t, UFScheduler*, hash<uintptr_t> > ThreadUFSchedulerMap;
+
+struct UFConnectionPool;
 struct UFScheduler
 {
     friend class UF;
@@ -211,6 +212,8 @@ public:
     std::vector<long long> _stats;
     UFMutex _stats_lock;
 
+    // connection pool
+    UFConnectionPool *_conn_pool;
 };
 
 inline UF* UFScheduler::getRunningFiberOnThisThread(){ return _currentFiber; }

Modified: trafficserver/traffic/branches/UserFiber/include/UFConnectionPool.H
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/UserFiber/include/UFConnectionPool.H?rev=943599&r1=943598&r2=943599&view=diff
==============================================================================
--- trafficserver/traffic/branches/UserFiber/include/UFConnectionPool.H (original)
+++ trafficserver/traffic/branches/UserFiber/include/UFConnectionPool.H Wed May 12 17:58:35 2010
@@ -11,7 +11,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-
+#include "UF.H"
 
 class StIpInfo;
 class UFConnectionGroupInfo;
@@ -24,7 +24,7 @@ public:
 
     // Call init before thread creation
     static void init();
-    
+
     unsigned int loadConfigFile(const std::string& fileName);
     unsigned int loadConfigFile(const std::string& fileName, int maxSimultaneousConns);
 
@@ -36,6 +36,7 @@ public:
     void setTimeoutIP(int timeoutIn); ///how long to timeout an ip that we cant connect to (is not responding)
     std::string fillInfo(std::string& data, bool detailed = false) const;
     double getGroupAvailability(const std::string& name) const;
+    void clearBadConnections();
 
     //TODO - get stats & detailed stats info
 protected:
@@ -44,6 +45,19 @@ protected:
 
 };
 
+struct UFConnectionPoolCleaner : public UF
+{
+    void run();
+    UFConnectionPoolCleaner (bool registerMe = false) : _conn_pool(NULL)
+    {
+//        if(registerMe)
+//            _myLoc = UFFactory::getInstance()->registerFunc((UF*)this);
+    }
+
+    UF* createUF() { return new UFConnectionPoolCleaner; }
+    UFConnectionPool* _conn_pool;
+};
+
 namespace StringUtil
 {
     typedef std::vector<std::string> StringVector;

Added: trafficserver/traffic/branches/UserFiber/src/Makefile
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/UserFiber/src/Makefile?rev=943599&view=auto
==============================================================================
--- trafficserver/traffic/branches/UserFiber/src/Makefile (added)
+++ trafficserver/traffic/branches/UserFiber/src/Makefile Wed May 12 17:58:35 2010
@@ -0,0 +1,33 @@
+CPP=c++
+BUILD_FLAGS=-g -O3 -Wall -DPIPE_NOT_EFD -Wno-deprecated -m32
+ARCH=x86-64
+AR=ar -rv
+RANLIB=ranlib
+INCLUDE_DIR=../include
+INCLUDE=-I../include
+LIB=../lib
+
+all:	libUF.a
+
+
+UF.o:	UF.C $(INCLUDE_DIR)/UF.H
+	$(CPP) $(BUILD_FLAGS) -c -o $(LIB)/UF.o UF.C -I../include -march=$(ARCH) 
+
+UFIO.o:	UFIO.C $(INCLUDE_DIR)/UFIO.H
+	$(CPP) $(BUILD_FLAGS) -c -o $(LIB)/UFIO.o UFIO.C $(INCLUDE) -march=$(ARCH)
+
+UFStatSystem.o: UFStatSystem.C $(INCLUDE_DIR)/UFStatSystem.H
+	$(CPP) $(BUILD_FLAGS) -c -o $(LIB)/UFStatSystem.o UFStatSystem.C $(INCLUDE) -march=$(ARCH)
+
+UFServer.o: UFServer.C $(INCLUDE_DIR)/UFServer.H
+	$(CPP) $(BUILD_FLAGS) -c -o $(LIB)/UFServer.o UFServer.C $(INCLUDE) -march=$(ARCH)
+
+UFConnectionPoolImpl.o: UFConnectionPoolImpl.C $(INCLUDE_DIR)/UFConnectionPool.H UFConnectionPoolImpl.H
+	$(CPP) $(BUILD_FLAGS) -c -o $(LIB)/UFConnectionPoolImpl.o UFConnectionPoolImpl.C $(INCLUDE) -march=$(ARCH)
+
+libUF.a:	UF.o UFIO.o UFStatSystem.o UFServer.o UFConnectionPoolImpl.o
+	$(AR) $(LIB)/libUF.a $(LIB)/UF.o $(LIB)/UFIO.o $(LIB)/UFStatSystem.o $(LIB)/UFServer.o $(LIB)/UFConnectionPoolImpl.o
+	$(RANLIB) $(LIB)/libUF.a
+
+clean: 
+	rm *.o *.a

Modified: trafficserver/traffic/branches/UserFiber/src/UF.C
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/UserFiber/src/UF.C?rev=943599&r1=943598&r2=943599&view=diff
==============================================================================
--- trafficserver/traffic/branches/UserFiber/src/UF.C (original)
+++ trafficserver/traffic/branches/UserFiber/src/UF.C Wed May 12 17:58:35 2010
@@ -1,4 +1,6 @@
 #include "UF.H"
+#include "UFConnectionPool.H"
+
 #include <string.h>
 
 #include <iostream>
@@ -110,6 +112,7 @@ UFScheduler::UFScheduler()
     _exitJustMe = false;
     _specific = 0;
     _currentFiber = 0;
+    _conn_pool = new UFConnectionPool;
 
     if(_inThreadedMode)
     {
@@ -154,6 +157,7 @@ UFScheduler::UFScheduler()
 UFScheduler::~UFScheduler()
 {
     pthread_key_delete(_specific_key);
+    delete _conn_pool;
 }
 
 
@@ -256,6 +260,12 @@ void UFScheduler::runScheduler()
     struct timeval now;
     struct timeval start,finish;
     gettimeofday(&start, 0);
+
+    // Add connection pool cleanup fiber
+    UFConnectionPoolCleaner *conn_pool_cleanup_fiber = new UFConnectionPoolCleaner;
+    conn_pool_cleanup_fiber->_conn_pool = _conn_pool;
+    addFiberToScheduler(conn_pool_cleanup_fiber);
+    
     while(!_exitJustMe && !_exit)
     {
         UFList::iterator beg = _activeRunningList.begin();