Browse Source

fix TC_Coroutine rpc all not open co
fix co examples bug

ruanshudong 2 năm trước cách đây
mục cha
commit
8b6fc35145

+ 1 - 1
examples/CoroutineDemo/BServer/config.conf

@@ -53,7 +53,7 @@
 
         <BAdapter>
             #ip:port:timeout
-            endpoint = tcp -h 127.0.0.1 -p 9100 -t 10000
+            endpoint = tcp -h 127.0.0.1 -p 9200 -t 10000
             #allow ip
             allow	 =
             #max connection num

+ 2 - 2
examples/CoroutineDemo/client/main.cpp

@@ -26,7 +26,7 @@ using namespace tars;
 
 Communicator* _comm;
 
-static string coroObj = "TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9100";
+static string coroObj = "TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9200";
 
 struct Param
 {
@@ -112,7 +112,7 @@ void parallelCall(int c)
 //{
 //    // _comm.setProperty("locator", "tars.tarsregistry.QueryObj@tcp -h 10.208.139.242 -p 17890 -t 10000");
 //    // _comm.setProperty("stat", "tars.tarsstat.StatObj");
-//    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9100");
+//    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9200");
 //}
 //
 //Test1::~Test1()

+ 1 - 1
examples/CoroutineDemo/testCoro/main.cpp

@@ -43,7 +43,7 @@ TestCoroutine::TestCoroutine(int iNum)
 : _num(iNum)
 {
 	// _comm.setProperty("locator", "tars.tarsregistry.QueryObj@tcp -h 10.208.139.242 -p 17890 -t 10000");
-    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9100");
+    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9200");
 	// _comm.stringToProxy(_sObj, _prx);
 }
 

+ 1 - 1
examples/CoroutineDemo/testParallelCoro/main.cpp

@@ -78,7 +78,7 @@ TestCoroutine::TestCoroutine(int iNum)
 : _num(iNum)
 {
 	// _comm.setProperty("locator", "tars.tarsregistry.QueryObj@tcp -h 10.208.139.242 -p 17890 -t 10000");
-    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9100");
+    _prx = _comm.stringToProxy<BServantPrx>("TestApp.BServer.BServantObj@tcp -h 127.0.0.1 -p 9200");
 	// _comm.stringToProxy(_sObj, _prx);
 }
 

+ 5 - 5
examples/scripts/run-co.sh

@@ -30,12 +30,12 @@ sleep 1
 echo "client: ${EXE_PATH}/CoroutineDemoClient"
 
 ${EXE_PATH}/CoroutineDemoClient --count=10000 --call=serial --thread=2 --buffersize=100 --netthread=2
-
+#
 ${EXE_PATH}/CoroutineDemoClient --count=10000 --call=parallel --thread=2 --buffersize=100 --netthread=2
-
-${EXE_PATH}/testCoro 1000
-
-${EXE_PATH}/testParallelCoro 1000
+#
+#${EXE_PATH}/testCoro 1000
+#
+#${EXE_PATH}/testParallelCoro 1000
 
 #-------------------------------------------------------------------------------------------------------
 

+ 1 - 0
servant/libservant/Application.cpp

@@ -730,6 +730,7 @@ void Application::main(const string &config)
 #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS
         TC_Common::ignorePipe();
 #endif
+    	__out__.modFlag(0xFFFF, false);
 
         //解析配置文件
         parseConfig(config);

+ 6 - 0
servant/libservant/ServantProxy.cpp

@@ -777,6 +777,12 @@ void ServantProxy::invoke(ReqMessage *msg, bool bCoroAsync)
     ServantProxyThreadData *pSptd = ServantProxyThreadData::getData();
     assert(pSptd != NULL);
 
+    //协程调用方式, 启用协程
+    if(bCoroAsync && TC_CoroutineScheduler::scheduler() && !pSptd->_sched)
+    {
+    	pSptd->_sched = TC_CoroutineScheduler::scheduler();
+    }
+
     msg->data = pSptd->move();
 
     // 调用链追踪透传