bool master_service::on_accept(acl::aio_socket_stream* client) { if (0) logger("connect from %s, fd %d", client->get_peer(true), client->sock_handle()); acl_non_blocking(client->sock_handle(), ACL_BLOCKING); // 根据客户端连接服务端口号的不同来区分不同的服务应用协议 const char* local = client->get_local(true); if (acl_strrncasecmp(local, var_cfg_backend_service, strlen(var_cfg_backend_service)) == 0) { // 创建服务对象处理来自于后端服务模块的请求 IConnection* conn = new ServerConnection(client); conn->run(); return true; } else { // 创建对象处理来自于前端客户端模块的请求 IConnection* conn = new ClientConnection(client, var_cfg_conn_expired); conn->run(); return true; } return true; }
static void scan_path(std::vector<std::string>& files) { acl::scan_dir scan; if (scan.open(".") == false) { printf("scan open error %s\r\n", acl::last_serror()); return; } const char* file; while ((file = scan.next_file(false)) != NULL) { if (acl_strrncasecmp(file, ".stub", 2) == 0) { char buf[1024]; snprintf(buf, sizeof(buf), "%s", file); char* dot = strrchr(buf, '.'); assert(dot); *dot = 0; strcat(buf, ".h"); assert(copy_file(file, buf)); files.push_back(buf); } } }
bool master_service::on_accept(acl::aio_socket_stream* client) { if (0) logger("connect from %s, fd %d", client->get_peer(true), client->sock_handle()); acl_non_blocking(client->sock_handle(), ACL_BLOCKING); IConnection* conn; // 根据客户端连接服务端口号的不同来区分不同的服务应用协议 const char* local = client->get_local(true); if (acl_strrncasecmp(local, var_cfg_backend_service, strlen(var_cfg_backend_service)) == 0) { // 创建服务对象处理来自于后端服务模块的请求 conn = new ServerConnection(client); } else if (acl_strrncasecmp(local, var_cfg_status_service, strlen(var_cfg_status_service)) == 0) { const char* ip = client->get_peer(); if (ip == NULL || *ip == 0) { logger_error("can't get peer ip"); return false; } if (allow_list::get_instance().allow_manager(ip) == false) { logger_warn("deny manager ip: %s", ip); return false; } // 创建服务对象处理状态汇报的请求 conn = new StatusConnection(client); } else // 创建对象处理来自于前端客户端模块的请求 conn = new ClientConnection(client, var_cfg_conn_expired); conn->run(); return true; }
void* CDelBOM::RunThread(void *arg) { CDelBOM* pDel = (CDelBOM*) arg; ACL_SCAN_DIR *scan = acl_scan_dir_open(pDel->m_sPath.GetString(), 1); if (scan == NULL) { CString msg; msg.Format("Open path %s error", pDel->m_sPath.GetString()); MessageBox(NULL, msg, "Open path", 0); ::PostMessage(pDel->m_hWnd, pDel->m_nMsgDeleted, 0, 0); return NULL; } while (true) { const char* pFile = acl_scan_dir_next_file(scan); if (pFile == NULL) break; // 过滤掉非纯文本的文件 if (acl_strrncasecmp(pFile, ".c", 2) && acl_strrncasecmp(pFile, ".cpp", 4) && acl_strrncasecmp(pFile, ".cxx", 4) && acl_strrncasecmp(pFile, ".h", 2) && acl_strrncasecmp(pFile, ".hpp", 4) && acl_strrncasecmp(pFile, ".hxx", 4) && acl_strrncasecmp(pFile, ".java", 5) && acl_strrncasecmp(pFile, ".txt", 4) && acl_strrncasecmp(pFile, ".php", 4) && acl_strrncasecmp(pFile, ".html", 5) && acl_strrncasecmp(pFile, ".js", 3) && acl_strrncasecmp(pFile, ".css", 4) && acl_strrncasecmp(pFile, ".d", 2) && acl_strrncasecmp(pFile, ".py", 3) && acl_strrncasecmp(pFile, ".perl", 5) && acl_strrncasecmp(pFile, ".cs", 3) && acl_strrncasecmp(pFile, ".as", 3)) { acl_msg_info(">>skip file: %s", pFile); continue; } CString filePath = acl_scan_dir_path(scan); filePath += "\\"; filePath += pFile; if (pDel->DeleteBOM(filePath) == true) acl_msg_info(">>modify file %s", filePath.GetString()); else acl_msg_info(">>skip file %s", filePath.GetString()); } acl_scan_dir_close(scan); ::PostMessage(pDel->m_hWnd, pDel->m_nMsgDeleted, 0, 0); acl_msg_info(">>scan over, msg: %d", pDel->m_nMsgDeleted); return NULL; }