├── README.md ├── document ├── ACE-6.2.0.tar.bz2 └── Teaf(isgw)框架设计和使用说明书.doc └── trunk └── teaf(isgw) ├── LICENSE.TXT ├── bin ├── keeper.sh ├── start.sh └── tools.inc ├── client ├── client.cpp ├── conn.php ├── makefile ├── server.cpp └── test.sh ├── comm ├── asy_prot.h ├── cmd_amount_contrl.cpp ├── cmd_amount_contrl.h ├── ibc_oper_base.cpp ├── ibc_oper_base.h ├── ibc_oper_fac.h ├── ibc_prot.h ├── isgw.stat.cfg ├── isgw_comm.cpp ├── isgw_comm.h ├── isgw_oper_base.cpp ├── isgw_oper_base.h ├── isgw_proxy.cpp ├── isgw_proxy.h ├── isgw_task_base.cpp ├── isgw_task_base.h ├── lua_oper.cpp ├── lua_oper.h ├── makefile.stat ├── plat_conn_mgr_asy.cpp ├── plat_conn_mgr_asy.h ├── plat_conn_mgr_ex.cpp ├── plat_conn_mgr_ex.h ├── plat_db_access.cpp ├── plat_db_access.h ├── plat_db_conn.cpp ├── plat_db_conn.h ├── pp_prot.h ├── qmode_msg.cpp ├── qmode_msg.h ├── rds_access.cpp ├── rds_access.h ├── readme.stat ├── shm_bitmap_manager.cpp ├── shm_bitmap_manager.h ├── stat.cpp ├── stat.h ├── sys_comm.cpp └── sys_comm.h ├── dll ├── dll_impl.cpp ├── dll_impl.h ├── dll_test.cpp ├── oper.cpp └── oper.h ├── easyace ├── ace_all.h ├── ace_app.cpp ├── ace_app.h ├── ace_conf.cpp ├── ace_conf.h ├── ace_object_array.cpp ├── ace_object_array.h ├── ace_object_que.cpp ├── ace_object_que.h ├── ace_svc.cpp ├── ace_svc.h ├── easyace.dsp ├── easyace.dsw ├── easyace_all.h ├── makefile └── readme.txt ├── frm ├── ace_sock_hdr_base.cpp ├── ace_sock_hdr_base.h ├── asy_task.cpp ├── asy_task.h ├── ibc_mgr_svc.cpp ├── ibc_mgr_svc.h ├── isgw_ack.cpp ├── isgw_ack.h ├── isgw_app.cpp ├── isgw_app.h ├── isgw_cintf.cpp ├── isgw_cintf.h ├── isgw_intf.cpp ├── isgw_intf.h ├── isgw_mgr_svc.cpp ├── isgw_mgr_svc.h ├── isgw_sighdl.cpp ├── isgw_sighdl.h ├── isgw_svrd.cpp ├── isgw_uintf.cpp └── isgw_uintf.h ├── install.sh ├── readme.txt ├── sql └── init.sql └── svr ├── admin_proxy_sync.cpp ├── admin_proxy_sync.h ├── ibc_oper_fac.cpp ├── isgw_config.h ├── isgw_svrd.ini ├── makefile ├── pdb_oper.cpp ├── pdb_oper.h ├── pdb_prot.h ├── start.sh ├── svrs.ini ├── temp_proxy.cpp └── temp_proxy.h /README.md: -------------------------------------------------------------------------------- 1 | # Teaf 简介 2 | Tencent Easy ACE Framework (简称Teaf),基于ACE的高性能轻量级服务框架,单进程多线程模型,支持select/epoll等多种网络IO模型,同时支持tcp和udp协议,支持二进制(pb等)和文本格式,相对多进程模型的框架来说更易维护,更轻量。业务侧只需要开发自己的逻辑处理即可实现高性能的业务后台服务器。已经在互娱(IEG)大部分平台类产品中成熟应用,比如idip,游戏人生,心悦,帮帮,新终端游戏中心aj,cross等,公司其他BG也有很多产品在使用。 3 | 4 | 具体的详细功能列表如下: 5 | * 单进程多线程模型,运营简单,相比于多进程模型有更高的性能和更少的cpu资源消耗; 6 | * 使用文本的协议(自定义或者json),易于理解,开发成本低;新增二进制(比如pb等)协议格式的支持; 7 | 3. 指令流量控制、请求量监控等特性; 8 | 4. 提供多种数据库,存储访问接口封装,包括mysql, redis等; 9 | 5. 提供统一的访问量数据采集(统计); 10 | 6. 可以支持消息路由转发; 11 | 7. 提供批量处理特性(常用于批量的好友信息查询); 12 | 8. 支持业务控制是否返回消息; 13 | 9. 支持和后端模块同步和异步两种连接管理模式; 14 | 10. 提供很多公共的工具函数或者常用类,比如加解密,编解码,字符集转换等; 15 | 16 | 性能参考数据:普通idc8核服务器(tlinux2.0 intel 2.53G CPU 8G 内存) 17 | 100+客户端,跑单个isgw/teaf 服务器进程,处理能力大概在6w qps,cpu总占用大概在170%(除以8就是21%,网络中断所在的cpu基本上跑满) 18 | 跑4个进程,处理能力在23w qps左右。 19 | 20 | #开发步骤 21 | 1. 从 IsgwOperBase 继承子类 22 | 2. 重新实现 IsgwOperBase* factory_method() 返回 继承的子类 23 | IsgwOperBase* factory_method() 24 | { 25 | TempProxy::init(); 26 | 27 | IsgwOperBase* obj = new PdbOper(); 28 | return obj; 29 | } 30 | 3. 实现子类中的 process函数 实现相应的业务逻辑 31 | int process(QModeMsg& req, char* ack, int& ack_len); 32 | 4. 编译及安装 33 | 34 | #样例程序 35 | svr/ 目录下有几个样例程序 比如 pdb_oper.cpp *oper.cpp 36 | 可以在svr目录下 make 编译体验一下 编译的时候注意需要依赖的库(如果没有mysql可以删掉跟db相关的文件即可) 37 | -------------------------------------------------------------------------------- /document/ACE-6.2.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/document/ACE-6.2.0.tar.bz2 -------------------------------------------------------------------------------- /document/Teaf(isgw)框架设计和使用说明书.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/document/Teaf(isgw)框架设计和使用说明书.doc -------------------------------------------------------------------------------- /trunk/teaf(isgw)/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | Tencent is pleased to support the open source community by making Teaf available. 2 | Copyright @2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | If you have downloaded a copy of the Teaf binary from Tencent, please note that the Teaf binary is licensed under the MIT License. 4 | If you have downloaded a copy of the Teaf source code from Tencent, please note that Teaf source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of Teaf into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within Teaf . 5 | A copy of the MIT License is included in this file. 6 | Other dependencies and licenses: 7 | 8 | Open Source Software Licensed Under the DOC Software License (the "License"): 9 | ---------------------------------------------------------------------------------------- 10 | 1. The ADAPTIVE Communication Environment (ACE) (6.0.0) 11 | Douglas C. Schmidt and his research group at Washington University, University of California, Irvine, and Vanderbilt University, Copyright @1993-2009 12 | All rights reserved 13 | 14 | 15 | 16 | Terms of the DOC Software License: 17 | --------------------------------------------------- 18 | Copyright and Licensing Information for ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), and CoSMIC(TM) 19 | ACE(TM), TAO(TM), CIAO(TM), DAnCE>(TM), and CoSMIC(TM) (henceforth referred to as "DOC software") are copyrighted by Douglas C. Schmidt and his research group at Washington University, University of California, Irvine, and Vanderbilt University, Copyright @ 1993-2009, all rights reserved. Since DOC software is open-source, freely available software, you are free to use, modify, copy, and distribute--perpetually and irrevocably--the DOC software source code and object code produced from the source, as well as copy and distribute modified versions of this software. You must, however, include this copyright statement along with any code built using DOC software that you release. No copyright statement needs to be provided if you just ship binary executables of your software products. 20 | You can use DOC software in commercial and/or binary software releases and are under no obligation to redistribute any of your source code that is built using DOC software. Note, however, that you may not misappropriate the DOC software code, such as copyrighting it yourself or claiming authorship of the DOC software code, in a way that will prevent DOC software from being distributed freely using an open-source development model. You needn't inform anyone that you're using DOC software in your software, though we encourage you to let us know so we can promote your project in the DOC software success stories. 21 | The ACE, TAO, CIAO, DAnCE, and CoSMIC web sites are maintained by the DOC Group at the Institute for Software Integrated Systems (ISIS) and the Center for Distributed Object Computing of Washington University, St. Louis for the development of open-source software as part of the open-source software community. Submissions are provided by the submitter ``as is'' with no warranties whatsoever, including any warranty of merchantability, noninfringement of third party intellectual property, or fitness for any particular purpose. In no event shall the submitter be liable for any direct, indirect, special, exemplary, punitive, or consequential damages, including without limitation, lost profits, even if advised of the possibility of such damages. Likewise, DOC software is provided as is with no warranties of any kind, including the warranties of design, merchantability, and fitness for a particular purpose, noninfringement, or arising from a course of dealing, usage or trade practice. Washington University, UC Irvine, Vanderbilt University, their employees, and students shall have no liability with respect to the infringement of copyrights, trade secrets or any patents by DOC software or any part thereof. Moreover, in no event will Washington University, UC Irvine, or Vanderbilt University, their employees, or students be liable for any lost revenue or profits or other special, indirect and consequential damages. 22 | DOC software is provided with no support and without any obligation on the part of Washington University, UC Irvine, Vanderbilt University, their employees, or students to assist in its use, correction, modification, or enhancement. A number of companies around the world provide commercial support for DOC software, however. DOC software is Y2K-compliant, as long as the underlying OS platform is Y2K-compliant. Likewise, DOC software is compliant with the new US daylight savings rule passed by Congress as "The Energy Policy Act of 2005," which established new daylight savings times (DST) rules for the United States that expand DST as of March 2007. Since DOC software obtains time/date and calendaring information from operating systems users will not be affected by the new DST rules as long as they upgrade their operating systems accordingly. 23 | The names ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), CoSMIC(TM), Washington University, UC Irvine, and Vanderbilt University, may not be used to endorse or promote products or services derived from this source without express written permission from Washington University, UC Irvine, or Vanderbilt University. This license grants no permission to call products or services derived from this source ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), or CoSMIC(TM), nor does it grant permission for the name Washington University, UC Irvine, or Vanderbilt University to appear in their names. 24 | If you have any suggestions, additions, comments, or questions, please let me know. 25 | Douglas C. Schmidt 26 | 27 | 28 | 29 | Terms of the MIT License: 30 | -------------------------------------------------------------------- 31 | 32 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 35 | 36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/bin/keeper.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/bin/keeper.sh -------------------------------------------------------------------------------- /trunk/teaf(isgw)/bin/start.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/bin/start.sh -------------------------------------------------------------------------------- /trunk/teaf(isgw)/bin/tools.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/bin/tools.inc -------------------------------------------------------------------------------- /trunk/teaf(isgw)/client/client.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/client/client.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/client/conn.php: -------------------------------------------------------------------------------- 1 | = 2) 7 | { 8 | $num = $argv[1]; 9 | } 10 | 11 | $sock = array(); 12 | $lastcidx = 1; 13 | 14 | for ($i = 1; $i <= $num; $i++) { 15 | $sock[$i] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 16 | //socket_set_nonblock($sock); 17 | if (socket_connect($sock[$i],"172.25.40.94", 5693) != TRUE) 18 | { 19 | for ($j = $lastcidx; $j <= $i; $j++) { 20 | socket_close($sock[$j]); 21 | } 22 | $lastcidx = $j; 23 | echo __FILE__.":".__LINE__." close sock to $lastcidx\n"; 24 | sleep (2); //连接失败就等一段时间再连 25 | } 26 | usleep(2000); 27 | 28 | } 29 | 30 | sleep (1000); 31 | echo __FILE__.":".__LINE__." test finish\n"; 32 | 33 | ?> -------------------------------------------------------------------------------- /trunk/teaf(isgw)/client/makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | CFLAGS= 3 | INCLUDE=-I../comm/ -I./ 4 | LIBS=-static -L/data/lib/lib -lACE -lnsl -lm -lz -lc -ldl -lpthread -lrt 5 | 6 | BINARY = $(patsubst %.cpp,%.o,$(wildcard *.cpp)) 7 | TARGET = client 8 | 9 | all:$(TARGET) 10 | 11 | $(TARGET):$(BINARY) 12 | $(CXX) $? -o $@ $(INCLUDE) $(CFLAGS) $(LIBS) 13 | %.o:%.cpp 14 | $(CXX) -c $< -o $@ $(INCLUDE) $(CFLAGS) 15 | 16 | clean: 17 | @rm -rf $(BINARY) $(TARGET) 18 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/client/server.cpp: -------------------------------------------------------------------------------- 1 | #include /* See NOTES */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int main () 11 | { 12 | int sockfd, new_fd; /* listen on sock_fd, new connection on new_fd */ 13 | struct sockaddr_in my_addr; /* my address information */ 14 | struct sockaddr_in their_addr; /* connector's address information */ 15 | socklen_t sin_size; 16 | if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) == -1) 17 | { 18 | perror ("socket"); 19 | exit (1); 20 | } 21 | memset (&their_addr, 0, sizeof (struct sockaddr)); 22 | my_addr.sin_family = AF_INET; /* host byte order */ 23 | my_addr.sin_port = htons (5690); /* short, network byte order */ 24 | my_addr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */ 25 | if (bind (sockfd, (struct sockaddr *) &my_addr, sizeof (struct sockaddr)) == -1) 26 | { 27 | perror ("bind"); 28 | exit (1); 29 | } 30 | if (listen (sockfd, 100) == -1) 31 | { 32 | perror ("listen"); 33 | exit (1); 34 | } 35 | int fpid = fork(); 36 | while (1) 37 | { /* main accept() loop */ 38 | sin_size = sizeof (struct sockaddr_in); 39 | if ((new_fd = accept (sockfd, (struct sockaddr *) &their_addr, &sin_size)) == -1) 40 | { 41 | perror ("accept"); 42 | continue; 43 | } 44 | printf ("server: got connection from %s in fpid=%d,pid=%d\n", inet_ntoa (their_addr.sin_addr), fpid, getpid()); 45 | if (send (new_fd, "Hello, world!\n", 14, 0) == -1) 46 | perror ("send"); 47 | close (new_fd); /* parent doesn't need this */ 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/client/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | uin=29320360 4 | while true 5 | do 6 | ./client 172.0.0.1 5693 "cmd=1&uin=$uin" 1000000 1 & 7 | uin=`expr $uin + 1` 8 | sleep 5 9 | done 10 | 11 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/asy_prot.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/asy_prot.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/cmd_amount_contrl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/cmd_amount_contrl.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/cmd_amount_contrl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/cmd_amount_contrl.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/ibc_oper_base.cpp: -------------------------------------------------------------------------------- 1 | #include "ibc_oper_base.h" 2 | 3 | int IBCOperBase::process(QModeMsg& req, char* ack, int& ack_len) 4 | { 5 | ACE_DEBUG((LM_DEBUG, "[%D] IBCOperBase start to process msg\n")); 6 | snprintf(ack, ack_len, "%s|", (*(req.get_map()))["info"].c_str()); 7 | 8 | return 0; 9 | } 10 | 11 | int IBCOperBase::merge(IBCRValue& rvalue, const char* new_item) 12 | { 13 | ACE_DEBUG((LM_DEBUG, "[%D] IBCOperBase start to merge msg\n")); 14 | if (new_item == NULL || strlen(new_item) == 0) 15 | { 16 | return -1; 17 | } 18 | 19 | strncat(rvalue.msg, new_item, sizeof(rvalue.msg)-strlen(rvalue.msg)); 20 | 21 | ACE_DEBUG((LM_DEBUG, "[%D] IBCOperBase merge msg succ" 22 | ",cnum=%d" 23 | "\n" 24 | , rvalue.cnum 25 | )); 26 | return 0; 27 | } 28 | 29 | int IBCOperBase::end(IBCRValue& rvalue) 30 | { 31 | ACE_DEBUG((LM_DEBUG, "[%D] IBCOperBase start to end\n")); 32 | 33 | //to do what you need 34 | 35 | 36 | ACE_DEBUG((LM_DEBUG, "[%D] IBCOperBase end succ" 37 | ",cnum=%d" 38 | "\n" 39 | , rvalue.cnum 40 | )); 41 | return 0; 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/ibc_oper_base.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/ibc_oper_base.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/ibc_oper_fac.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/ibc_oper_fac.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/ibc_prot.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/ibc_prot.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw.stat.cfg: -------------------------------------------------------------------------------- 1 | isgw sub-system 2 | reqs of cmd ISGW_TEST -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_comm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_comm.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_comm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_comm.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_oper_base.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_oper_base.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_oper_base.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_oper_base.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_proxy.cpp: -------------------------------------------------------------------------------- 1 | #include "isgw_proxy.h" 2 | #include 3 | 4 | const std::string IsgwProxy::ADMIN_SERVER1("172.27.128.79"); 5 | const std::string IsgwProxy::ADMIN_SERVER2("10.130.136.205"); 6 | const uint16_t IsgwProxy::ADMIN_PORT = 6888; 7 | 8 | int IsgwProxy::get(const std::string& req, std::string& rsp) 9 | { 10 | // 取服务器ip 11 | std::string server; 12 | int ret = get_server(server); 13 | if(ret != 0) 14 | { 15 | return ret; 16 | } 17 | 18 | // 发送请求, 接收回应 19 | ret = get(server, port_, timeout_, req, rsp); 20 | 21 | // 统计 22 | pthread_mutex_lock(&mutex_); 23 | for(std::vector >::iterator it = servers_.begin(); 24 | it != servers_.end(); ++it) 25 | { 26 | if(server != it->first) 27 | { 28 | continue; 29 | } 30 | 31 | ++it->second.total; 32 | if(ret != 0) 33 | { 34 | ++it->second.fail; 35 | } 36 | else 37 | { 38 | it->second.fail = 0; 39 | } 40 | } 41 | 42 | pthread_mutex_unlock(&mutex_); 43 | return ret; 44 | } 45 | 46 | std::map IsgwProxy::parse(const std::string& input) 47 | { 48 | std::map data; 49 | std::string name, value; 50 | std::string::size_type pos; 51 | std::string::size_type oldPos = 0; 52 | 53 | // Parse the input in one fell swoop for efficiency 54 | while(true) 55 | { 56 | // Find the '=' separating the name from its value 57 | pos = input.find_first_of("=", oldPos); 58 | 59 | // If no '=', we're finished 60 | if(std::string::npos == pos) 61 | { 62 | break; 63 | } 64 | 65 | // Decode the name 66 | name = input.substr(oldPos, pos - oldPos); 67 | oldPos = ++pos; 68 | 69 | // Find the '&' separating subsequent name/value pairs 70 | pos = input.find_first_of("&", oldPos); 71 | 72 | // Even if an '&' wasn't found the rest of the string is a value 73 | value = input.substr(oldPos, pos - oldPos); 74 | 75 | // Store the pair 76 | data[name] = value; 77 | if(std::string::npos == pos) 78 | { 79 | break; 80 | } 81 | 82 | // Update parse position 83 | oldPos = ++pos; 84 | } 85 | 86 | return data; 87 | } 88 | 89 | std::vector IsgwProxy::split(const std::string& src, char delim) 90 | { 91 | std::vector elems; 92 | std::stringstream ss(src); 93 | std::string item; 94 | while (std::getline(ss, item, delim)) 95 | { 96 | if(!item.empty()) 97 | { 98 | elems.push_back(item); 99 | } 100 | } 101 | return elems; 102 | } 103 | 104 | int IsgwProxy::get_server(std::string& server) 105 | { 106 | unsigned now = static_cast(time(0)); 107 | if(now > last_refresh_time_ + refresh_server_interval_) 108 | { 109 | std::vector servers; 110 | int ret = get_servers(port_, timeout_, servers); 111 | if(ret == 0 && now > last_refresh_time_ + refresh_server_interval_) 112 | { 113 | pthread_mutex_lock(&mutex_); 114 | 115 | // 打印各server的访问次数 116 | for(std::vector >::const_iterator cit = servers_.begin(); 117 | cit != servers_.end(); ++cit) 118 | { 119 | std::cout << cit->first << ": " << cit->second.total << " " << cit->second.fail << std::endl; 120 | } 121 | 122 | servers_.clear(); 123 | for(std::vector::const_iterator cit = servers.begin(); 124 | cit != servers.end(); ++cit) 125 | { 126 | std::pair elem; 127 | elem.first = *cit; 128 | servers_.push_back(elem); 129 | } 130 | 131 | last_refresh_time_ = now; 132 | server_index_ = 0; 133 | 134 | pthread_mutex_unlock(&mutex_); 135 | } 136 | } 137 | 138 | pthread_mutex_lock(&mutex_); 139 | size_t size = servers_.size(); 140 | if(size == 0) 141 | { 142 | pthread_mutex_unlock(&mutex_); 143 | return IPEC_NO_SERVER; 144 | } 145 | 146 | // 取下一个可用的server 147 | int index = (server_index_ + 1) % size; 148 | for(; index != server_index_; index = (index + 1) % size) 149 | { 150 | if(servers_[index].second.fail < max_fail_times_) 151 | { 152 | break; 153 | } 154 | } 155 | 156 | // 所有server均不可用, 就取下一个 157 | if(index == server_index_) 158 | { 159 | index = (server_index_ + 1) % size; 160 | } 161 | 162 | server = servers_[index].first; 163 | server_index_ = index; 164 | pthread_mutex_unlock(&mutex_); 165 | return 0; 166 | } 167 | 168 | int IsgwProxy::get_servers(uint16_t port, int32_t timeout, std::vector& servers) 169 | { 170 | std::vector admin_servers; 171 | 172 | // get admin server from dns 173 | struct addrinfo hints, *res; 174 | memset(&hints, 0, sizeof(hints)); 175 | hints.ai_family = AF_INET; 176 | hints.ai_socktype = SOCK_STREAM; 177 | int ret = ::getaddrinfo("admin.igame.ied.com", "", &hints, &res); 178 | if(ret == 0) 179 | { 180 | for(struct addrinfo* p = res; p != NULL; p = p->ai_next) 181 | { 182 | char ip[INET6_ADDRSTRLEN] = {0}; 183 | ::inet_ntop(p->ai_family, &((struct sockaddr_in *)p->ai_addr)->sin_addr, ip, sizeof(ip)); 184 | if(ip[0] == '\0') 185 | { 186 | continue; 187 | } 188 | 189 | std::cout << "get admin server from dns: " << ip << std::endl; 190 | admin_servers.push_back(ip); 191 | } 192 | 193 | freeaddrinfo(res); 194 | } 195 | 196 | // DNS解析失败时, 用写死的ip 197 | if(admin_servers.empty()) 198 | { 199 | admin_servers.push_back(ADMIN_SERVER1); 200 | admin_servers.push_back(ADMIN_SERVER2); 201 | } 202 | 203 | // 从admin server请求服务IP列表 204 | ret = 0; 205 | for(std::vector::const_iterator cit = admin_servers.begin(); 206 | cit != admin_servers.end(); ++cit) 207 | { 208 | std::ostringstream oss; 209 | oss << "cmd=921&port=" << port << "&expire=" << DEF_INTERVAL << "\n"; 210 | 211 | std::string rsp; 212 | ret = get(*cit, ADMIN_PORT, timeout, oss.str(), rsp); 213 | if(ret != 0) 214 | { 215 | continue; 216 | } 217 | 218 | // 解析rsp 219 | std::map data = parse(rsp); 220 | ret = data.count("result") ? atoi(data.at("result").c_str()) : -1; 221 | if(ret != 0) 222 | { 223 | continue; 224 | } 225 | 226 | servers = split(data["info"], ' '); 227 | if(!servers.empty()) 228 | { 229 | break; 230 | } 231 | } 232 | 233 | if(ret != 0) 234 | { 235 | return ret; 236 | } 237 | 238 | if(servers.empty()) 239 | { 240 | return IPEC_NO_SERVER; 241 | } 242 | 243 | return 0; 244 | } 245 | 246 | int IsgwProxy::get(const std::string& server, uint16_t port, int32_t timeout, const std::string& req, std::string& rsp) 247 | { 248 | // 建立套接字 249 | int fd = ::socket(AF_INET, SOCK_STREAM, 0); 250 | if(fd == -1) 251 | { 252 | return IPEC_SOCKET_ERROR; 253 | } 254 | 255 | int flags = -1; 256 | if(flags = ::fcntl(fd, F_GETFL), flags == -1) 257 | { 258 | ::close(fd); 259 | return IPEC_SOCKET_ERROR; 260 | } 261 | 262 | flags |= O_NONBLOCK; 263 | if(::fcntl(fd, F_SETFL, flags) == -1) 264 | { 265 | ::close(fd); 266 | return IPEC_SOCKET_ERROR; 267 | } 268 | 269 | // 连接 270 | struct sockaddr_in addr; 271 | addr.sin_family = AF_INET; 272 | addr.sin_port = htons(port); 273 | addr.sin_addr.s_addr = ::inet_addr(server.c_str()); 274 | int ret = ::connect(fd, (struct sockaddr*)&addr, sizeof(addr)); 275 | if(ret == -1 && errno != EINPROGRESS) 276 | { 277 | ::close(fd); 278 | return IPEC_CONNECT_FAIL; 279 | } 280 | 281 | // 非阻塞的connect 282 | if(ret != 0) 283 | { 284 | struct pollfd fds[1]; 285 | fds[0].fd = fd; 286 | fds[0].events = POLLOUT; 287 | 288 | ret = ::poll(fds, 1, timeout); 289 | if(ret == -1) 290 | { 291 | ::close(fd); 292 | return IPEC_CONNECT_FAIL; 293 | } 294 | 295 | if(ret == 0) 296 | { 297 | ::close(fd); 298 | return IPEC_TIMEOUT; 299 | } 300 | 301 | int err = 0; 302 | socklen_t errlen = static_cast(sizeof(err)); 303 | ret = ::getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&err, &errlen); 304 | if(ret == -1) 305 | { 306 | ::close(fd); 307 | return IPEC_CONNECT_FAIL; 308 | } 309 | 310 | if(err) 311 | { 312 | ::close(fd); 313 | return IPEC_CONNECT_FAIL; 314 | } 315 | } 316 | 317 | // 发送 318 | ret = ::send(fd, req.c_str(), req.size(), 0); 319 | // 发送失败或发送不完全 320 | if(ret == -1 || ret != static_cast(req.size())) 321 | { 322 | ::close(fd); 323 | return IPEC_SEND_FAIL; 324 | } 325 | 326 | // 接收 327 | rsp.clear(); 328 | struct timeval start, end; 329 | for(::gettimeofday(&start, NULL); 330 | timeout >= 0; 331 | ::gettimeofday(&end, NULL), timeout -= ((end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec)) / 1000) 332 | { 333 | struct pollfd fds[1]; 334 | fds[0].fd = fd; 335 | fds[0].events = POLLIN | POLLPRI; 336 | 337 | ret = ::poll(fds, 1, timeout); 338 | if(ret == -1) 339 | { 340 | ::close(fd); 341 | return IPEC_RECV_FAIL; 342 | } 343 | 344 | if(ret == 0) 345 | { 346 | ::close(fd); 347 | return IPEC_TIMEOUT; 348 | } 349 | 350 | char buf[65536] = {0}; 351 | ret = ::recv(fd, buf, sizeof(buf), 0); 352 | if(ret == -1) 353 | { 354 | ::close(fd); 355 | return IPEC_RECV_FAIL; 356 | } 357 | 358 | size_t i = 0; 359 | for(; i < sizeof(buf) && buf[i] != '\n'; ++i); 360 | rsp.append(buf, i); 361 | if(buf[i] == '\n') 362 | { 363 | ::close(fd); 364 | return 0; 365 | } 366 | } 367 | 368 | ::close(fd); 369 | return IPEC_TIMEOUT; 370 | } 371 | 372 | #if 0 373 | int main() 374 | { 375 | IsgwProxy proxy(5696, 50, 60); 376 | std::string rsp; 377 | proxy.get("cmd=434&uin=476794193\n", rsp); 378 | std::cout << rsp << std::endl; 379 | 380 | for(int i = 0; i < 100000; ++i) 381 | { 382 | proxy.get("cmd=434&uin=476794193\n", rsp); 383 | // std::cout << rsp << std::endl; 384 | ::usleep(10000); 385 | } 386 | } 387 | 388 | #endif 389 | 390 | 391 | 392 | 393 | 394 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_proxy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_proxy.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_task_base.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_task_base.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/isgw_task_base.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/isgw_task_base.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/lua_oper.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by away on 15/6/16. 3 | // 4 | 5 | #include 6 | #include "lua_oper.h" 7 | 8 | LuaOper* LuaOper::oper_; 9 | //lua_State* LuaOper::lua_state_; 10 | LUA_STATE_MAP LuaOper::state_map_; 11 | 12 | LuaOper* LuaOper::instance() 13 | { 14 | // 暂时不考虑加锁 只在单线程中执行 15 | if (NULL == oper_) 16 | { 17 | oper_ = new LuaOper; 18 | } 19 | return oper_; 20 | } 21 | 22 | lua_State * LuaOper::init() 23 | { 24 | unsigned int threadid = syscall(__NR_gettid); //ACE_OS::thr_self(); 25 | lua_State *lua_state = state_map_[threadid]; 26 | 27 | if(lua_state != NULL) 28 | { 29 | close(lua_state); 30 | } 31 | 32 | lua_state = luaL_newstate(); 33 | luaopen_base(lua_state); 34 | luaL_openlibs(lua_state); 35 | luaL_loadfile(lua_state, "./process.lua"); 36 | 37 | //好像必须调用 不然函数找不到 38 | lua_pcall(lua_state, 0, LUA_MULTRET, 0); 39 | 40 | state_map_[threadid] = lua_state; 41 | ACE_DEBUG((LM_INFO, "[%D] LuaOper init lua succ threadid=%d\n", threadid)); 42 | 43 | return state_map_[threadid]; 44 | } 45 | 46 | int LuaOper::process(const char *req, char* ack, int& ack_len) 47 | { 48 | unsigned int threadid = syscall(__NR_gettid); //ACE_OS::thr_self(); 49 | lua_State *lua_state = state_map_[threadid]; 50 | if(lua_state == NULL) 51 | { 52 | lua_state = init(); 53 | } 54 | 55 | size_t len; 56 | lua_getglobal(lua_state, "process"); 57 | lua_pushstring(lua_state, req); 58 | lua_call(lua_state, 1, 1); 59 | snprintf(ack, ack_len, "%s", lua_tolstring(lua_state, -1, &len)); 60 | ack_len = len; 61 | lua_pop(lua_state, 1); 62 | return 0; 63 | } 64 | 65 | int LuaOper::close(lua_State *lua_state) 66 | { 67 | if(lua_state != NULL) 68 | { 69 | lua_close(lua_state); 70 | lua_state = NULL; 71 | } 72 | else 73 | { 74 | LUA_STATE_MAP::iterator it; 75 | for(it=state_map_.begin(); it!=state_map_.end(); it++) 76 | { 77 | lua_close(it->second); 78 | it->second = NULL; 79 | } 80 | } 81 | return 0; 82 | } -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/lua_oper.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Tencent is pleased to support the open source community by making Teaf available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at http://opensource.org/licenses/MIT 6 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 7 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8 | * See the License for the specific language governing permissions and limitations under the License. 9 | ******************************************************************************/ 10 | // 11 | // Created by away on 15/6/16. 12 | // 13 | 14 | #ifndef ISGW_LUAOPER_H 15 | #define ISGW_LUAOPER_H 16 | #include "isgw_comm.h" 17 | 18 | extern "C"{ 19 | #include "lua.h" 20 | #include "lualib.h" 21 | #include "lauxlib.h" 22 | }; 23 | 24 | typedef map LUA_STATE_MAP; 25 | 26 | class LuaOper { 27 | public: 28 | LuaOper(){}; 29 | virtual ~LuaOper(){} 30 | static LuaOper* instance(); 31 | 32 | lua_State * init(); 33 | int process(const char *req, char* ack, int& ack_len); 34 | int close(lua_State *lua_state); 35 | 36 | private: 37 | // 目前不支持多线程,需要优化成每个线程有自己的 lua_state 38 | static LUA_STATE_MAP state_map_; 39 | //static lua_State *lua_state_; 40 | static LuaOper* oper_; 41 | }; 42 | 43 | 44 | #endif //ISGW_LUAOPER_H 45 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/makefile.stat: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | CFLAGS= -g -D_STAT_DEMO_ 3 | INCLUDE=-I./ -I/usr/local/include/ace -I../easyace/ 4 | LIBS=-static -L./ -lACE -lnsl -lm -lz -lc -ldl -lpthread -lrt 5 | 6 | BINARY = stat.o 7 | TARGET = stat_tool 8 | 9 | all:$(TARGET) 10 | 11 | $(TARGET):$(BINARY) 12 | $(CXX) -o $(TARGET) $(BINARY) $(LIBS) $(CFLAGS) 13 | 14 | stat.o:stat.cpp 15 | $(CXX) -c $< -o $@ $(INCLUDE) $(CFLAGS) 16 | 17 | clean: 18 | @rm -rf $(TARGET) $(BINARY) -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_conn_mgr_asy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_conn_mgr_asy.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_conn_mgr_asy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_conn_mgr_asy.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_conn_mgr_ex.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_conn_mgr_ex.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_conn_mgr_ex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_conn_mgr_ex.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_db_access.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_db_access.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_db_access.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_db_access.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_db_conn.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_db_conn.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/plat_db_conn.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/plat_db_conn.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/pp_prot.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/pp_prot.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/qmode_msg.cpp: -------------------------------------------------------------------------------- 1 | #include "qmode_msg.h" 2 | #include 3 | #include 4 | 5 | #ifdef BINARY_PROTOCOL 6 | QModeMsg::QModeMsg(const int len, const char* body, unsigned int sock_fd, unsigned int sock_seq 7 | , unsigned int msg_seq, unsigned int prot, unsigned int time, unsigned int sock_ip 8 | , unsigned short port) 9 | : sock_fd_(sock_fd), sock_seq_(sock_seq), msg_seq_(msg_seq), prot_(prot), time_(time) 10 | , sock_ip_(sock_ip), sock_port_(port) 11 | { 12 | cmd_ = 0; 13 | uin_ = 0; 14 | rflag_ = 0; 15 | memcpy(body_, body, len); 16 | body_len_ = len; 17 | } 18 | 19 | #endif 20 | 21 | QModeMsg::QModeMsg(const char* body, unsigned int sock_fd, unsigned int sock_seq 22 | , unsigned int msg_seq, unsigned int prot, unsigned int time, unsigned int sock_ip 23 | , unsigned short port) 24 | : sock_fd_(sock_fd), sock_seq_(sock_seq), msg_seq_(msg_seq), prot_(prot), time_(time) 25 | , sock_ip_(sock_ip), sock_port_(port) 26 | { 27 | cmd_ = 0; 28 | uin_ = 0; 29 | rflag_ = 0; 30 | gettimeofday(&tvtime_, NULL); 31 | //memset(body_, 0x0, sizeof(body_)); 32 | set_body(body); 33 | 34 | } 35 | 36 | QModeMsg::QModeMsg(void) 37 | { 38 | body_len_ = 0; 39 | sock_fd_ = 0; 40 | sock_seq_ = 0; 41 | msg_seq_ = 0; 42 | prot_ = 0; 43 | time_ = 0; 44 | sock_ip_ = 0; 45 | sock_port_ = 0; 46 | cmd_ = 0; 47 | uin_ = 0; 48 | rflag_ = 0; 49 | gettimeofday(&tvtime_, NULL); 50 | } 51 | 52 | QModeMsg::~QModeMsg() 53 | { 54 | msg_map_.clear(); 55 | } 56 | 57 | QMSG_MAP* QModeMsg::get_map() 58 | { 59 | return &msg_map_; 60 | } 61 | 62 | const char* QModeMsg::get_body() const 63 | { 64 | return body_; 65 | } 66 | 67 | void QModeMsg::set_body(const char* body) 68 | { 69 | if (body != NULL) 70 | { 71 | body_len_ = snprintf(body_, QMSG_MAX_LEN, "%s", body); 72 | if(body_len_ > QMSG_MAX_LEN) body_len_ = QMSG_MAX_LEN; 73 | parse_msg(); 74 | } 75 | } 76 | 77 | void QModeMsg::set(const char* body, unsigned int sock_fd, unsigned int sock_seq 78 | , unsigned int msg_seq, unsigned int prot, unsigned int time 79 | , unsigned int sock_ip, unsigned short port) 80 | { 81 | set_body(body); 82 | 83 | sock_fd_ = sock_fd; 84 | sock_seq_ = sock_seq; 85 | msg_seq_ = msg_seq; 86 | prot_ = prot; 87 | time_ = time; 88 | sock_ip_ = sock_ip; 89 | sock_port_ = port; 90 | } 91 | 92 | unsigned int QModeMsg::get_cmd() 93 | { 94 | return cmd_; 95 | } 96 | 97 | unsigned int QModeMsg::get_uin() 98 | { 99 | return uin_; 100 | } 101 | 102 | unsigned int QModeMsg::get_rflag() 103 | { 104 | return rflag_; 105 | } 106 | 107 | int QModeMsg::get_result() 108 | { 109 | char* p = strstr(body_, FIELD_NAME_RESULT); 110 | if (p == NULL) 111 | { 112 | return ERROR_NO_FIELD; 113 | } 114 | 115 | return atoi(((msg_map_)[FIELD_NAME_RESULT]).c_str()); 116 | } 117 | 118 | int QModeMsg::parse_msg() 119 | { 120 | msg_map_.clear(); 121 | if(body_len_>0&&'\r'==body_[body_len_-1]) body_[body_len_-1] = '\0'; 122 | char tmp_body[body_len_+1]; 123 | snprintf(tmp_body, sizeof(tmp_body), "%s", body_); 124 | 125 | char name[QMSG_NAME_LEN]; 126 | char* ptr = NULL; 127 | char* p = strtok_r(tmp_body, QMSG_SEP, &ptr); 128 | while (p != NULL) 129 | { 130 | char* s = strchr(p, '='); 131 | if (s != NULL) 132 | { 133 | int name_len = s - p > sizeof(name)-1 ? sizeof(name)-1 : s - p; 134 | snprintf(name, name_len+1, "%s", p); 135 | msg_map_[name] = s + 1; 136 | } 137 | p = strtok_r(NULL, QMSG_SEP, &ptr); 138 | } 139 | 140 | cmd_ = atoi(((msg_map_)[FIELD_NAME_CMD]).c_str()); 141 | uin_ = strtoul(((msg_map_)[FIELD_NAME_UIN]).c_str(), NULL, 10); 142 | rflag_ = atoi(((msg_map_)["_rflag"]).c_str()); 143 | 144 | return 0; 145 | } 146 | 147 | unsigned int QModeMsg::get_handle() 148 | { 149 | return sock_fd_; 150 | } 151 | 152 | unsigned int QModeMsg::get_sock_seq() 153 | { 154 | return sock_seq_; 155 | } 156 | 157 | unsigned int QModeMsg::get_msg_seq() 158 | { 159 | return msg_seq_; 160 | } 161 | 162 | unsigned int QModeMsg::get_prot() 163 | { 164 | return prot_; 165 | } 166 | 167 | unsigned int QModeMsg::get_time() 168 | { 169 | return time_; 170 | } 171 | 172 | unsigned int QModeMsg::get_sock_ip() 173 | { 174 | return sock_ip_; 175 | } 176 | 177 | unsigned short QModeMsg::get_sock_port() 178 | { 179 | return sock_port_; 180 | } 181 | 182 | unsigned int QModeMsg::get_body_size() 183 | { 184 | return body_len_; 185 | } 186 | 187 | int QModeMsg::is_have(const char * field_name) 188 | { 189 | if (field_name == NULL) 190 | { 191 | return ERROR_PARA_ILL; 192 | } 193 | 194 | char* p = strstr(body_, field_name); 195 | if (p==NULL) 196 | { 197 | return -1; 198 | } 199 | 200 | return 0; 201 | } 202 | 203 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/qmode_msg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/qmode_msg.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/rds_access.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/rds_access.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/rds_access.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/rds_access.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/readme.stat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/readme.stat -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/shm_bitmap_manager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/shm_bitmap_manager.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/shm_bitmap_manager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/shm_bitmap_manager.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/stat.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/stat.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/stat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/stat.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/sys_comm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/sys_comm.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/comm/sys_comm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/comm/sys_comm.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/dll/dll_impl.cpp: -------------------------------------------------------------------------------- 1 | //g++ dll_impl.cpp -fPIC -shared -o libperson.so 2 | #include "dll_impl.h" 3 | 4 | person::person(const string& name, unsigned int age) : m_name(name), m_age(age) 5 | { 6 | cout << m_name << " say hello!" << endl; 7 | }; 8 | 9 | person::~person() 10 | { 11 | cout << m_name << " say byebye!" << endl; 12 | }; 13 | 14 | string person::get_person_name() const {return m_name;} 15 | 16 | person create_person(const string& name, unsigned int age) 17 | { 18 | return person(name, age); 19 | }; 20 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/dll/dll_impl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/dll/dll_impl.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/dll/dll_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/dll/dll_test.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/dll/oper.cpp: -------------------------------------------------------------------------------- 1 | // g++ oper.cpp -fPIC -shared -o liboper.so -lACE -I./ -I/usr/local/include/ace -I../../easyace/ -I../comm/ 2 | #include "oper.h" 3 | #include "easyace_all.h" 4 | 5 | int oper_init() 6 | { 7 | return 0; 8 | } 9 | 10 | int oper_proc(char* req, char* ack, int& ack_len) 11 | { 12 | ACE_DEBUG((LM_DEBUG, "oper start to proc\n")); 13 | 14 | snprintf(ack, ack_len, "info=%s", req); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/dll/oper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/dll/oper.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_all.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Tencent is pleased to support the open source community by making Teaf available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at http://opensource.org/licenses/MIT 6 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 7 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8 | * See the License for the specific language governing permissions and limitations under the License. 9 | ******************************************************************************/ 10 | #ifndef _ACE_ALL_H_ 11 | #define _ACE_ALL_H_ 12 | 13 | #include "ace/LOCK_SOCK_Acceptor.h" 14 | #include "ace/Auto_Ptr.h" 15 | #include "ace/Reactor.h" 16 | #include "ace/Thread_Manager.h" 17 | #include "ace/Synch.h" 18 | #include "ace/Get_Opt.h" 19 | #include "ace/Logging_Strategy.h" 20 | #include "ace/Log_Msg.h" 21 | #include "ace/Service_Object.h" 22 | #include "ace/svc_export.h" 23 | #include "ace/SOCK_Acceptor.h" 24 | #include "ace/SOCK_Connector.h" 25 | #include "ace/Date_Time.h" 26 | #include "ace/Time_Value.h" 27 | #include "ace/Atomic_Op_T.h" 28 | #include "ace/Configuration.h" 29 | #include "ace/Configuration_Import_Export.h" 30 | #include "ace/SOCK_Connector.h" 31 | #include "ace/SOCK_Dgram.h" 32 | #include "ace/Mem_Map.h" 33 | #include "ace/Svc_Handler.h" 34 | #include "ace/Acceptor.h" 35 | #include "ace/Connector.h" 36 | #include "ace/TP_Reactor.h" 37 | #include "ace/Singleton.h" 38 | #include "ace/Service_Config.h" 39 | #include "ace/ARGV.h" 40 | #include "ace/Reactor_Notification_Strategy.h" 41 | #include "ace/OS_NS_sys_msg.h" 42 | #include "ace/OS_NS_arpa_inet.h" 43 | //#include "ace/OS.h" 44 | #include "ace/Basic_Types.h" 45 | #include "ace/Version.h" 46 | #include "ace/OS_NS_dlfcn.h" 47 | #include "ace/DLL.h" 48 | #include "ace/DLL_Manager.h" 49 | 50 | #if ((ACE_MAJOR_VERSION > 5 || (ACE_MAJOR_VERSION==5 && ACE_MINOR_VERSION>=6)) && defined (ACE_HAS_EVENT_POLL) ) 51 | #include "ace/Dev_Poll_Reactor.h" 52 | #endif 53 | #if ((ACE_MAJOR_VERSION > 5 || (ACE_MAJOR_VERSION==5 && ACE_MINOR_VERSION>=6)) && defined (ACE_HAS_EVENT_POLL) ) 54 | typedef ACE_Reactor_Token_T ACE_Select_Reactor_Noop_Token; 55 | typedef ACE_Select_Reactor_T ACE_Select_Reactor_N; 56 | #else 57 | typedef ACE_Select_Reactor_Token_T ACE_Select_Reactor_Noop_Token; 58 | typedef ACE_Select_Reactor_T ACE_Select_Reactor_N; 59 | #endif 60 | 61 | #endif // _ACE_ALL_H_ 62 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_app.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_app.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_app.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_app.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_conf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_conf.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_conf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_conf.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_object_array.cpp: -------------------------------------------------------------------------------- 1 | #include "ace_object_array.h" 2 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_object_array.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_object_array.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_object_que.cpp: -------------------------------------------------------------------------------- 1 | #include "ace_object_que.h" 2 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_object_que.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_object_que.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_svc.cpp: -------------------------------------------------------------------------------- 1 | #include "ace_svc.h" 2 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/ace_svc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/ace_svc.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/easyace.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="easyace" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=easyace - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "easyace.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "easyace.mak" CFG="easyace - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "easyace - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "easyace - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "easyace - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x804 /d "NDEBUG" 46 | # ADD RSC /l 0x804 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "easyace - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x804 /d "_DEBUG" 69 | # ADD RSC /l 0x804 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "easyace - Win32 Release" 82 | # Name "easyace - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=.\ace_app.cpp 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=.\oi_tea.cpp 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=.\sys_comm.cpp 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=.\sys_conf.cpp 101 | # End Source File 102 | # End Group 103 | # Begin Group "Header Files" 104 | 105 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 106 | # Begin Source File 107 | 108 | SOURCE=.\ace_app.h 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=.\oi_tea.h 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\sys_comm.h 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\sys_conf.h 121 | # End Source File 122 | # End Group 123 | # End Target 124 | # End Project 125 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/easyace.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "easyace"=.\easyace.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/easyace_all.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Tencent is pleased to support the open source community by making Teaf available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at http://opensource.org/licenses/MIT 6 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 7 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8 | * See the License for the specific language governing permissions and limitations under the License. 9 | ******************************************************************************/ 10 | #ifndef _EASYACE_ALL_H_ 11 | #define _EASYACE_ALL_H_ 12 | 13 | #include "ace_all.h" 14 | #include "ace_conf.h" 15 | #include "ace_app.h" 16 | #include "ace_svc.h" 17 | #include "ace_object_que.h" 18 | #include "ace_object_array.h" 19 | 20 | #include "sys_comm.h" 21 | 22 | #endif //_EASYACE_ALL_H_ 23 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | 3 | CFLAGS=-g -I/usr/local/include/ -I../../comm/ 4 | LDFLAGS=-static 5 | 6 | ifeq ($(BIT), 64) 7 | CFLAGS:=$(CFLAGS) -m64 8 | LDFLAGS:=$(LDFLAGS) -shared -fPIC 9 | TARGET:=libeasyace_lib$(BIT).a 10 | else 11 | BIT:=32 12 | CFLAGS:=$(CFLAGS) -m32 13 | LDFLAGS:=$(LDFLAGS) -shared -fPIC -m elf_i386 14 | TARGET:=libeasyace_lib$(BIT).a 15 | endif 16 | 17 | INCLUDE= 18 | LIBS= $(LDFLAGS) -lACE 19 | 20 | BINARY = $(patsubst %.cpp,%.o,$(wildcard *.cpp)) 21 | 22 | all:$(TARGET) 23 | 24 | %.o:%.cpp 25 | $(CXX) -c $< -o $@ $(INCLUDE) $(CFLAGS) 26 | 27 | $(TARGET):$(BINARY) 28 | @rm -rf $@ 29 | ar rcs $@ $^ 30 | ln -s $@ libeasyace.a 31 | 32 | clean: 33 | @rm -rf ${BINARY} $(TARGET) 34 | 35 | pkg: 36 | tar -czvf easyace.tgz ../easyace/*.h ../easyace/*.cpp ../easyace/*.txt ../easyace/easyace.* ../easyace/makefile* 37 | 38 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/easyace/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/easyace/readme.txt -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/ace_sock_hdr_base.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/ace_sock_hdr_base.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/ace_sock_hdr_base.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/ace_sock_hdr_base.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/asy_task.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/asy_task.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/asy_task.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/asy_task.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/ibc_mgr_svc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/ibc_mgr_svc.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/ibc_mgr_svc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/ibc_mgr_svc.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_ack.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_ack.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_ack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_ack.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_app.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_app.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_app.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_app.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_cintf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_cintf.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_cintf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_cintf.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_intf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_intf.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_intf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_intf.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_mgr_svc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_mgr_svc.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_mgr_svc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_mgr_svc.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_sighdl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_sighdl.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_sighdl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_sighdl.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_svrd.cpp: -------------------------------------------------------------------------------- 1 | #include "isgw_app.h" 2 | 3 | int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) 4 | { 5 | ISGWApp the_app; 6 | if (the_app.init(argc, argv) != 0) 7 | { 8 | return -1; 9 | } 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_uintf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_uintf.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/frm/isgw_uintf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/frm/isgw_uintf.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/install.sh: -------------------------------------------------------------------------------- 1 | if [ $# -lt 1 ] 2 | then 3 | { 4 | echo "Usage:$0 " 5 | exit 1 6 | } 7 | fi 8 | 9 | SVRD_NAME=$1 10 | export ISGW_HOME=/usr/local/isgw/ 11 | 12 | mkdir bin cfg log 13 | ln -s $ISGW_HOME/svr/$SVRD_NAME bin/ 14 | ln -s $ISGW_HOME/svr/$SVRD_NAME.ini cfg/ 15 | ln -s $ISGW_HOME/svr/svrs.ini cfg/ 16 | 17 | if [ "`pwd`" != "$ISGW_HOME" ] 18 | then 19 | { 20 | ln -s $ISGW_HOME/bin/start.sh bin/ 21 | ln -s $ISGW_HOME/bin/keeper.sh bin/ 22 | } 23 | fi 24 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/readme.txt -------------------------------------------------------------------------------- /trunk/teaf(isgw)/sql/init.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/sql/init.sql -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/admin_proxy_sync.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/admin_proxy_sync.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/admin_proxy_sync.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/admin_proxy_sync.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/ibc_oper_fac.cpp: -------------------------------------------------------------------------------- 1 | #include "ibc_oper_fac.h" 2 | #include "ibc_oper_base.h" 3 | #include "stat.h" 4 | #include "pdb_prot.h" 5 | 6 | #ifdef IBC_SVRD 7 | #include "ibc_get_news.h" 8 | #include "ibc_get_glist.h" 9 | #endif 10 | 11 | IBCOperBase* IBCOperFac::create_oper(int cmd) 12 | { 13 | IBCOperBase* oper = NULL; 14 | switch (cmd) 15 | { 16 | default: 17 | oper = new IBCOperBase; 18 | Stat::instance()->incre_stat(CMD_IBC_TEST); 19 | } 20 | return oper; 21 | } 22 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/isgw_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/isgw_config.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/isgw_svrd.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/isgw_svrd.ini -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ -g 2 | CFLAGS= -DPDB -DADMIN_OPER #-DISGW_USE_LUA #-DISGW_USE_ASY #-DISGW_USE_IBC -DISGW_USE_DLL -DVIP_OPER -DWEBGAME_OPER 3 | INCLUDE= -I./ -I/data/lib/include/ace -I../easyace/ -I/usr/local/include/mysql/ -I../comm/ -I../frm -I../../comm/ -I/usr/local/include/hiredis/ 4 | 5 | #ISGW_USE_DLL = 1 6 | ifdef ISGW_USE_DLL 7 | LIBS= -L./ -L/usr/local/lib/ -L../../comm/\ 8 | /data/lib/lib/libACE.a -lnsl -lm -lz -lc -ldl -lpthread -lrt #-llua /usr/local/lib/libmysqlclient_r.a -lhiredis 9 | else 10 | LIBS= -L./ -L/usr/local/lib/ -L../../comm/ -L/data/lib/lib/\ 11 | -static -lACE -lnsl -lm -lz -lc -ldl -lpthread -lrt #-llua -lmysqlclient_r -lhiredis 12 | endif 13 | 14 | BINARY = $(patsubst %.cpp,%.o,$(wildcard *.cpp)) 15 | TARGET = isgw_svrd 16 | 17 | all:$(TARGET) 18 | 19 | $(TARGET):$(BINARY) 20 | $(CXX) $? -o $@ $(INCLUDE) $(CFLAGS) $(LIBS) 21 | %.o:%.cpp 22 | $(CXX) -c $< -o $@ $(INCLUDE) $(CFLAGS) 23 | 24 | conf: 25 | ln -s ../comm/sys_comm.cpp 26 | ln -s ../comm/isgw_comm.cpp 27 | ln -s ../comm/qmode_msg.cpp 28 | #ln -s ../comm/plat_db_access.cpp 29 | #ln -s ../comm/plat_db_conn.cpp 30 | ln -s ../comm/plat_conn_mgr_ex.cpp 31 | ln -s ../comm/plat_conn_mgr_asy.cpp 32 | ln -s ../comm/stat.cpp 33 | ln -s ../comm/ibc_oper_base.cpp 34 | ln -s ../comm/isgw_oper_base.cpp 35 | ln -s ../comm/cmd_amount_contrl.cpp 36 | ln -s ../comm/isgw_task_base.cpp 37 | #ln -s ../comm/lua_oper.cpp 38 | #ln -s ../comm/rds_access.cpp 39 | ln -s ../frm/isgw_svrd.cpp 40 | ln -s ../frm/isgw_app.cpp 41 | ln -s ../frm/isgw_intf.cpp 42 | ln -s ../frm/isgw_uintf.cpp 43 | ln -s ../frm/isgw_cintf.cpp 44 | ln -s ../frm/ace_sock_hdr_base.cpp 45 | ln -s ../frm/isgw_ack.cpp 46 | ln -s ../frm/isgw_mgr_svc.cpp 47 | ln -s ../frm/ibc_mgr_svc.cpp 48 | ln -s ../frm/isgw_sighdl.cpp 49 | ln -s ../frm/asy_task.cpp 50 | ln -s ../easyace/*.cpp ./ 51 | 52 | clean: 53 | @rm -r ${TARGET} $(BINARY) 54 | 55 | cleanconf: 56 | @rm -r sys_comm.cpp isgw_uintf.cpp isgw_comm.cpp qmode_msg.cpp plat_db_conn.cpp plat_db_access.cpp \ 57 | isgw_svrd.cpp isgw_app.cpp isgw_intf.cpp ace_sock_hdr_base.cpp isgw_ack.cpp isgw_mgr_svc.cpp \ 58 | stat.cpp ibc_oper_base.cpp ibc_mgr_svc.cpp plat_conn_mgr_ex.cpp plat_conn_mgr_asy.cpp rds_access.cpp \ 59 | isgw_cintf.cpp isgw_oper_base.cpp cmd_amount_contrl.cpp isgw_sighdl.cpp asy_task.cpp isgw_task_base.cpp \ 60 | ace_app.cpp ace_conf.cpp ace_object_que.cpp ace_svc.cpp lua_oper.cpp rds_access.cpp ace_object_array.cpp 61 | -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/pdb_oper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/pdb_oper.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/pdb_oper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/pdb_oper.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/pdb_prot.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/pdb_prot.h -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/start.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/start.sh -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/svrs.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/svrs.ini -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/temp_proxy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/temp_proxy.cpp -------------------------------------------------------------------------------- /trunk/teaf(isgw)/svr/temp_proxy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentOpen/Teaf/09930215e4666cafcef2a2e47785e0a0913286ac/trunk/teaf(isgw)/svr/temp_proxy.h --------------------------------------------------------------------------------