squid-2.6.STABLE13 修改手记
来源:互联网 发布:淘宝图片保护在哪里看 编辑:程序博客网 时间:2024/05/16 13:58
squid 2.6.STABLE13 中cache_peer 中weight分配有问题,不能达到预期效果,这些算法很简单,不知道为什么开发者会出这样的问题,而一直也没有修正,网上一直也没有出一个完整的解决方法,以下是魔鬼对源代码的修改
修改 cache_cf.c中parse_peer函数,让weight可以为0,原来weigth小于1就赋值为1, 效果是当weight<=0,关闭cache_peer:
static void
parse_peer(peer ** head)
{
...
if (peerFindByName(p->name))
fatalf("ERROR: cache_peer %s specified twice/n", p->name);
/ * 注释掉原来的分配算法 * /
/ *
if (p->weight < 1)
p->weight = 1;
* /
/ * 注释代码结束 * /
/ * 加入下列代码 * /
/ *
* change by devil, weight=0, the peer is disable
* /
if (p->weight < 0)
p->weight = 0;
/ * 加入代码结束 * /
p->icp.version = ICP_VERSION_CURRENT;
p->test_fd = -1;
#if USE_CACHE_DIGESTS
if (!p->options.no_digest) {
p->digest = peerDigestCreate(p);
cbdataLock(p->digest); / * so we know when/if digest disappears * /
}
#endif
...
}
修改neighbors.c中getRoundRobinParent函数,修正不正确的weight分配:
peer *
getRoundRobinParent(request_t * request)
{
peer *p;
peer *q = NULL;
for (p = Config.peers; p; p = p->next) {
if (!p->options.roundrobin)
continue;
if (neighborType(p, request) != PEER_PARENT)
continue;
if (!peerHTTPOkay(p, request))
continue;
/ * 注释原有算法 * /
/ *
if (p->weight == 1) { / * round-bin * /
/ * 当前选中的peer分配count小于当前peer分配count则继续匹配下一个peer * /
if (q && q->rr_count < p->rr_count)
continue;
} else if (p->weight == 0 || (q && q->rr_count < (p->rr_count / p->weight))) {
/ * q->weight 应该与p->weight对应才能正确选择 * /
continue;
}
* /
/ * 注释结束 * /
/ * 加入如下代码 * /
/ *
* Change by devil
* /
if (p->weight > 0) {
if (q && (q->rr_count / q->weight) < (p->rr_count / p->weight))
continue;
} else
continue;
/ * 加入代码结束 * /
q = p;
}
if (q)
q->rr_count++;
debug(15, 3) ("getRoundRobinParent: returning %s/n", q ? q->host : "NULL");
return q;
}
重新编译安装过后使用squidclient mgr:server_list 查看Peer Cache Statistics中peer分配状态
- squid-2.6.STABLE13 修改手记
- squid服务器重新安装手记
- CentOS 4.4下Squid配置手记
- NDoc修改手记
- ---Warkey 界面修改手记
- squid for WIN + DNSPOD 搭建CDN服务器手记
- NDoc修改手记(二)
- 第二个论文修改手记
- 修改源码去除Squid版本信息
- 修改Squid参数提高缓存效果
- Squid
- squid
- squid
- Squid
- Squid
- squid
- Squid
- squid
- squid 编译参数
- 动态规划——最大子矩阵和
- 叉乘法求三角形的面积及任意多边形面积
- 您试图在此 Web 服务器上访问的 Web 应用程序当前不可用。
- 无限级别DropDownList(jQuery 1.3)
- squid-2.6.STABLE13 修改手记
- [转载] C语言中如何使用宏 包括单双井号 可变参数
- 转载-----C# 设计模式 - 1 接口模式 - 1.1 适配器模式
- 泛型算法系列20:reverse()&&reverse_copy()
- 【转】单例模式完全剖析
- POJ 1426 见证模余的力量!
- JDK1.5新特性(转)
- oracle 10g rac for linux (ASM) 修改modify public IP and vip
- emacs初学,大家有意见就提哈