??xml version="1.0" encoding="utf-8" standalone="yes"?>中文字幕精品久久,久久精品?ⅴ无码中文字幕,一本一道久久精品综合http://www.shnenglu.com/jinq0123/category/5139.htmlzh-cnThu, 14 Jun 2018 00:15:15 GMTThu, 14 Jun 2018 00:15:15 GMT60etcd+registrator+confd 服务发现http://www.shnenglu.com/jinq0123/archive/2018/06/13/215722.html金庆(jin)金庆(jin)Wed, 13 Jun 2018 06:27:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/06/13/215722.htmlhttp://www.shnenglu.com/jinq0123/comments/215722.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/06/13/215722.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215722.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215722.htmletcd+registrator+confd 服务发现

(金庆(jin)的专?2018.6)

因ؓ(f)k8s使用 etcd, 所以?etcd 作ؓ(f)服务发现?DB.

registrator 可以?docker 方式q行的服务自动注册到 etcd.

confd d etcd, 生成配置文g?br />
先运行一个etcd用于试Q?br />
docker run -d \
  -p 12379:2379 \
  --name jinqing-etcd \
  quay.io/coreos/etcd \
   /usr/local/bin/etcd \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://0.0.0.0:12379

再运?registrator:

docker run -d --rm \
    --name=jinqing-registrator \
    --net=host \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    gliderlabs/registrator:latest \
      -ip="192.168.93.183" \
      etcd://127.0.0.1:12379/registrator

好像只能使用本机?etcd. 一般需要用-ip参数指定本机IP。注册到 registrator 目录?br />
?etcdkeeper 可以查看自动注册的服务。registrator 不支?etcd v3.

然后配置 confd

mkdir -p /etc/confd/{conf.d,templates}

/etc/confd/conf.d/myconfig.toml

[template]
src = "services.toml.tmpl"
dest = "/tmp/services.toml"
keys = [
    "/registrator",
]

/etc/confd/templates/services.toml.tmpl

[config]
{{- range lsdir "/registrator"}}
{{-     $serviceName := . }}
{{-     $serviceDir := printf "/registrator/%s/*" $serviceName }}

    [config.{{ $serviceName }}]
    # {{ $serviceDir }}

{{-     range gets $serviceDir }}
    {{ base .Key }} = {{ .Value }}
{{-     end }}

{{- end}}

# End of [config].

?lsdir 列出所有服务目录,然后?gets 取服务目录下的键值对?br />
执行 confd:

~/go/bin/confd -onetime -backend etcd -node http://127.0.0.1:12379

[jinqing@localhost confd]$ cat /tmp/services.toml
[config]

    [config.etcd-2379]
    # /registrator/etcd-2379/*
    localhost.tech:jinqing-etcd:2379 = 192.168.93.183:12379

    [config.nginx]
    # /registrator/nginx/*
    localhost.tech:jinqing-nginx:80 = 192.168.93.183:1024

    [config.registry]
    # /registrator/registry/*
    localhost.tech:registry:5000 = 192.168.93.183:5000

# End of [config].


金庆(jin) 2018-06-13 14:27 发表评论
]]>
用docker stack开启redis集群http://www.shnenglu.com/jinq0123/archive/2017/10/26/215308.html金庆(jin)金庆(jin)Thu, 26 Oct 2017 04:08:00 GMThttp://www.shnenglu.com/jinq0123/archive/2017/10/26/215308.htmlhttp://www.shnenglu.com/jinq0123/comments/215308.htmlhttp://www.shnenglu.com/jinq0123/archive/2017/10/26/215308.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215308.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215308.html用docker stack开启redis集群

(金庆(jin)的专?2017.10)

?个docker swarm节点Q开启redis cluster.
每个机器上开2个redis节点Q共10个redis节点?br />采用官方的redis:alpine镜像?br />
docker-stack.yml 如下Q?br />
version: "3"
services:
  redis001:
    image: redis:alpine
    volumes:
      - /home/redis/001/data:/data
      - /home/redis/001/conf:/conf
    command: redis-server --appendonly yes --cluster-enabled yes --cluster-config-file /conf/nodes.conf --cluster-announce-ip 10.240.79.8 --cluster-announce-port 7001 --cluster-announce-bus-port 17001
    ports:
      - "7001:6379"
      - "17001:16379"
    networks:
      - redisnet
    deploy:
      placement:
        constraints:
          - node.hostname == host-10-240-79-8

  redis002:
    image: redis:alpine
    volumes:
      - /home/redis/002/data:/data
      - /home/redis/002/conf:/conf
    command: redis-server --appendonly yes --cluster-enabled yes --cluster-config-file /conf/nodes.conf --cluster-announce-ip 10.240.79.9 --cluster-announce-port 7002 --cluster-announce-bus-port 17002
    ports:
      - "7002:6379"
      - "17002:16379"
    networks:
      - redisnet
    deploy:
      placement:
        constraints:
          - node.hostname == host-10-240-79-9

  redis003:
  ...
  redis010:
    ...
 
networks:
  redisnet:

数据保存文g?/home/redis/001/data
集群配置文g保存到 /home/redis/001/conf/nodes.conf  
各机器上目录需要预先创建,不然docker开启失败?br />q且需要设|目录权限,不然?Permission denied".
redis-server以用户uid=100(redis)q行Q所?br />    chown -R 100 /home/redis/

启动redis服务?
    docker stack deploy -c docker-stack.yml redis

redis-server启动后,q行 redis-trib.rb 来组?redis cluster:

    docker run --rm -it inem0o/redis-trib create --replicas 1 10.240.79.8:7001 10.240.79.9:7002 ... 10.240.79.12:7010

注意 inem0o/redis-trib 的说明中Q命令示例缺?"-it", ?x)报错退出:(x)
Can I set the above configuration? (type 'yes' to accept): : undefined method `chomp' for nil:NilClass (NoMethodError)
        from /usr/bin/redis-trib:1295:in `create_cluster_cmd'
        from /usr/bin/redis-trib:1701:in `<main>'

q行 redis-cli 试Q?-c" 参数表示集群Q可q接L机器?001-7010L端口Q?br />[root@host-10-240-79-9 ~]# docker run -it --rm redis:alpine redis-cli -h 10.240.79.8 -p 7006 -c
10.240.79.8:7006> get a
-> Redirected to slot [15495] located at 10.240.79.10:7003
(nil)

用swarm mode开启redis服务比较方便?br />但是Z性能考虑Q应该禁?swarm 的NAT转发和负载均衡?br />研究?jin)下Q暂时还没学?x)?br />


金庆(jin) 2017-10-26 12:08 发表评论
]]>
CentOS升Svn到最新版http://www.shnenglu.com/jinq0123/archive/2015/04/23/210429.html金庆(jin)金庆(jin)Thu, 23 Apr 2015 08:54:00 GMThttp://www.shnenglu.com/jinq0123/archive/2015/04/23/210429.htmlhttp://www.shnenglu.com/jinq0123/comments/210429.htmlhttp://www.shnenglu.com/jinq0123/archive/2015/04/23/210429.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/210429.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/210429.htmlCentOS升Svn到最新版
(金庆(jin)的专?

CentOS/RHEL yum 安装?subversion ?1.6.11 版本Q?br />qVisulaSVN服务器时?x)?Key usage violation"Q?br />
[jinq@jinqing-centos ~]$ svn co https://.../server
svn: OPTIONS of 'https://.../server': SSL handshake failed: SSL error: Key usage violation in certificate has been detected. (https://...)

subversion升到最新版可解册错误?br />
Install Subversion 1.8.9 ( SVN Client ) on CentOS/RHEL
Thanks to Wandisco, which is maintaining the rpm packages for latest Subversion version.
( http://tecadmin.net/install-subversion-1-8-on-centos-rhel/ )

按指C|新的yum源,然后安装.

[jinq@jinqing-centos ~]$ svn --version
svn, version 1.8.13 (r1667537)
   compiled Apr  2 2015, 15:55:22 on x86_64-unknown-linux-gnu
  


金庆(jin) 2015-04-23 16:54 发表评论
]]>
boost::coroutine 无法昄调用?/title><link>http://www.shnenglu.com/jinq0123/archive/2014/11/07/208808.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Fri, 07 Nov 2014 01:45:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2014/11/07/208808.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/208808.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2014/11/07/208808.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/208808.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/208808.html</trackback:ping><description><![CDATA[<div>boost::coroutine 无法昄调用?br /><br />Q金?jin)的专栏Q?br /><br />一例因 boost::format() 格式化参C数错误造成?coredump,<br />因ؓ(f)使用?boost::coroutine, 无法昄异常时的调用栈,<br />仅显CZ(jin)异常的类型:(x)<br /><br /><span style="color: #000080; font-family: Courier;">#0  raise()</span><br /><span style="color: #000080; font-family: Courier;">#1  abort()</span><br /><span style="color: #000080; font-family: Courier;">#2  __gnu_cxx::__verbose_terminate_handler()</span><br /><span style="color: #000080; font-family: Courier;">#3  ??</span><br /><span style="color: #000080; font-family: Courier;">#4  std::terminate()</span><br /><span style="color: #000080; font-family: Courier;">#5  __cxa_throw()</span><br /><span style="color: #000080; font-family: Courier;">#6  boost::exception_detail::clone_impl<</span><br /><span style="color: #000080; font-family: Courier;">      boost::exception_detail::error_info_injector<</span><br /><span style="color: #000080; font-family: Courier;">        boost::io::too_many_args> >::rethrow()</span><br /><span style="color: #000080; font-family: Courier;">    at /usr/include/boost/exception/exception.hpp:466</span><br /><span style="color: #000080; font-family: Courier;">#7  boost::rethow_exception()</span><br /><span style="color: #000080; font-family: Courier;">    at /usr/include/boost/exception/detail/exception_ptr.hpp:458</span><br /><span style="color: #000080; font-family: Courier;">#8  boost::coroutine::detail::coroutine_base_resume<</span><br /><span style="color: #000080; font-family: Courier;">      void(), boost::coroutines::detail::coroutine_base<void()>, void, 0></span><br /><span style="color: #000080; font-family: Courier;">        ::resume(void)</span><br /><span style="color: #000080; font-family: Courier;">    at /usr/include/boost/coroutine/v1/detail/coroutine_base_resume.hpp:57</span><br /><span style="color: #000080; font-family: Courier;">#9  boost::coroutines::detail::coroutine_op<void(), </span><br /><span style="color: #000080; font-family: Courier;">      boost::coroutines::coroutine<void(), 0>, void, 0>::operator()(void)</span><br /><span style="color: #000080; font-family: Courier;">    at /usr/include/boost/coroutine/v1/detail/coroutine_op.hpp:46</span><br /><span style="color: #000080; font-family: Courier;">#10 PlayerCoro::operator()</span><br /><span style="color: #000080; font-family: Courier;">    at /home/jinqing/mnt/code/server/loginserver/PlayerCoro.h</span><br />   </div><img src ="http://www.shnenglu.com/jinq0123/aggbug/208808.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2014-11-07 09:45 <a href="http://www.shnenglu.com/jinq0123/archive/2014/11/07/208808.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>双线服务器策略\p|?/title><link>http://www.shnenglu.com/jinq0123/archive/2014/10/24/208667.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Fri, 24 Oct 2014 09:05:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2014/10/24/208667.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/208667.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2014/10/24/208667.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/208667.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/208667.html</trackback:ping><description><![CDATA[<div>双线服务器策略\p|?br /><p><br /></p><p>Q金?jin)的专栏Q?/p><p><br /></p>?sh)信|通双U服务器Q发现只有电(sh)信用戯q,|通不通?br />l运l检查,发现是策略\由没做好?br />d?jin)策略\由后正怺(jin)?br /><br />双线服务器有2个外|网卡,一个配?sh)信IP, 一个配|通IP.<br />{略路由让电(sh)信网的数据走?sh)信|卡Q电(sh)信网? |通的数据走网通的|卡Q网通网兟?br /><br />配置Ҏ(gu)如下Q?br /><br />1. 创徏 /etc/rc.d/route.sh<br />需要更攚w面的|关地址和服务器地址.<br /><br /><span style="color:#660000;">#!/bin/bash<br />echo '1' > /proc/sys/net/ipv4/ip_forward<br />sed -i -e '/252 dianxin/d' /etc/iproute2/rt_tables<br />sed -i -e '/251 wangtong/d' /etc/iproute2/rt_tables<br />echo '252 dianxin' >> /etc/iproute2/rt_tables<br />echo '251 wangtong' >> /etc/iproute2/rt_tables<br />IF_DIANXIN=eth1<br />IF_WANGTONG=eth2<br />GW_DIANXIN=222.73.123.129<br />GW_WANGTONG=112.65.123.129<br />IP_DIANXIN=222.73.123.45<br />IP_WANGTONG=112.65.123.45<br />ip route flush table dianxin<br />ip route flush table wangtong<br />ip route add default via $GW_DIANXIN dev eth1 table dianxin<br />ip route add default via $GW_WANGTONG dev eth2 table wangtong<br />ip rule add from $IP_DIANXIN table dianxin<br />ip rule add from $IP_WANGTONG table wangtong<br />ip rule add fwmark 1 table dianxin<br />ip rule add fwmark 2 table wangtong<br /></span><br />2. chmod 755 /etc/rc.d/route.sh 赋权<br />3. 执行一?/etc/rc.d/route.sh<br />4. /etc/rc.d/rc.local文g中加?etc/rc.d/route.sh, 使之开机启?br /><br />如果按照q个办法发现端口不通。只?U可能?br />1、脚本里面IP写错?jin)?br />2、服务器本地没有启动端口?br />3、本地防火墙挡住?jin)?br />4、交换机端口没有开放?br /><br />光因网兛_错,脚本执行报错Q?br />RTNETLINK answers: no such process<br />|关Ҏ(gu)后就没有错了(jin)?br /><br />开通交换机端口和网兛_址询问运营^台的同事?/div><img src ="http://www.shnenglu.com/jinq0123/aggbug/208667.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2014-10-24 17:05 <a href="http://www.shnenglu.com/jinq0123/archive/2014/10/24/208667.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>内核自动分配端口可?/title><link>http://www.shnenglu.com/jinq0123/archive/2014/10/07/208507.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Tue, 07 Oct 2014 09:38:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2014/10/07/208507.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/208507.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2014/10/07/208507.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/208507.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/208507.html</trackback:ping><description><![CDATA[<div>内核自动分配端口可?br /><br />Q金?jin)的专栏Q?br /><br />因ؓ(f)单机开多区试Ӟ因ؓ(f)Tcpq接比较多,很容易出现端口号被占用而无法开启服务进E的情况?br />例如某个q程q接MySql本地端口号ؓ(f)34567Q正好该端口是另一个服务进E的监听端口?br />本地端口h内核自动分配的一个空闲端口?br />内核自动分配端口可围配|于<br />    /proc/sys/net/ipv4/ip_local_port_range<br />它的值应该是32768?1000?br />所以服务进E的监听端口号应该配成小?2768?br /></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/208507.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2014-10-07 17:38 <a href="http://www.shnenglu.com/jinq0123/archive/2014/10/07/208507.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gcov辅助脚本http://www.shnenglu.com/jinq0123/archive/2014/09/26/208428.html金庆(jin)金庆(jin)Fri, 26 Sep 2014 13:02:00 GMThttp://www.shnenglu.com/jinq0123/archive/2014/09/26/208428.htmlhttp://www.shnenglu.com/jinq0123/comments/208428.htmlhttp://www.shnenglu.com/jinq0123/archive/2014/09/26/208428.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/208428.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/208428.htmlgcov辅助脚本

Q金?jin)的专栏Q?br />
代码覆盖试查看l果Ӟ需要进入代码所在目录,调用gcovQ然后vi查看?br />
因ؓ(f)代码目录l构复杂Q进出子目录太麻?ch),所以用以下脚本直接生成与查看?br />
一般是用TSVN列出有更改的文gQ将文g列表复制到文本,然后复制其中的CPP文g名作为参敎ͼ在代码根目录下执行脚本?br />
#!/bin/sh
# gcov.sh
# Usage: gcov.sh abc.sh
# Find file and cd to it, then call gcov and vim the result.

if [ $# -eq 0 ]
then
    echo Usage: $0 SOURCE_FILE
    echo Example: $0 abc.cpp
    exit
fi

DIR=`find . -name $1.gcda -exec dirname {} \;`
cd ${DIR}
gcov $1.gcda
vim +/##### $1.gcov

说明Q?br />find 在当前目录下查找文g?br />dirname 在查扄果中获取目录?br />cd q入目录
gcov 在该目录下执?gcov
vim 打开gcov输出文gQ参?+/##### 用于查找 ##### q蟩到该行?br />    ##### 是源代码未执行的标记?br />    
该脚本不能处理多个文件具有相同文件名的情c(din)?br />

金庆(jin) 2014-09-26 21:02 发表评论
]]>
shell脚本整段注释http://www.shnenglu.com/jinq0123/archive/2014/04/01/206413.html金庆(jin)金庆(jin)Tue, 01 Apr 2014 01:55:00 GMThttp://www.shnenglu.com/jinq0123/archive/2014/04/01/206413.htmlhttp://www.shnenglu.com/jinq0123/comments/206413.htmlhttp://www.shnenglu.com/jinq0123/archive/2014/04/01/206413.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/206413.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/206413.html摘自Qhttp://zhidao.baidu.com/link?url=XmCCZmfluRe6n8TjPRKJTx4GGOUPSGX1VNBm-euqGdpKGpveTESxC0HL90UBNT5nZCvmvfq2oIJdP3JO5EoPSq

利用shellI句注释整D代?br />
: << COMMENTBLOCK
   shell脚本代码D?br />COMMENTBLOCK
q个用来注释整段脚本代码?: 是shell中的I句?br />

金庆(jin) 2014-04-01 09:55 发表评论
]]>
gcov l计 inline 函数http://www.shnenglu.com/jinq0123/archive/2014/02/28/205983.html金庆(jin)金庆(jin)Fri, 28 Feb 2014 04:36:00 GMThttp://www.shnenglu.com/jinq0123/archive/2014/02/28/205983.htmlhttp://www.shnenglu.com/jinq0123/comments/205983.htmlhttp://www.shnenglu.com/jinq0123/archive/2014/02/28/205983.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/205983.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/205983.html

gcov l计 inline 函数

Q金?jin)的专栏Q?/p>


gcov可以l计 inline  函数Q可是实际用中到l计ơ数L?的现象?/p>


假设cA的头文g?A.h, 实现文g?A.cpp.

A 有几?inline  成员函数定义?A.h 中?/p>

使用 gcov  l计 A 的代码覆盖率Ӟ可能?x)发?A.h 中的 inline 成员调用ơ数为空??/p>

除了(jin)实未调用的原因Q可能是 gcov l计的对象错?jin)?/p>

"gcov A.cpp" l计的是 A.cpp 中实现的函数代码Q如?A.cpp  中未调用自n?inline  函数Q统计结果确实ؓ(f)0?/p>

只有到这?inline 的调用方 cpp 文g中去l计Q才?x)有惌的结果?/p>

例如QB.cpp 中调用了(jin) A ?inline  函数Q?gcov B.cpp" 才会(x)l计?inline 代码.

参考:(x)

Why the inline function can not be covered?


另外QCMake  构徏?o文g命名不是 A.o,  而是 A.cpp.o,  所?/p>

gcov A.cpp

?x)?A.gcno 不存在?/p>

实际文g应该?A.cpp.gcno.

 把它复制?A.gcno p?jin)?/p>

或者用

gcov A.cpp.gcda

不知Z么,可以直接?gcda 文g作ؓ(f)输入?/p>

或?/p>

gcov -o A.cpp.o A.cpp

q样应该是标准的调用方式?/p>

金庆(jin) 2014-02-28 12:36 发表评论
]]>
Linux~译Windows׃n目录下代?/title><link>http://www.shnenglu.com/jinq0123/archive/2014/02/26/205948.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Wed, 26 Feb 2014 03:47:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2014/02/26/205948.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/205948.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2014/02/26/205948.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/205948.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/205948.html</trackback:ping><description><![CDATA[<div>Linux~译Windows׃n目录下代?br /><br />Q金?jin)的专栏Q?br /><br />万神服务器代码是跨^台的。^时策划在Windows上开自己的服务器试Q测试和发布服务器ؓ(f)Linux.<br />开发时Q先在Windows上编译测试,再到Linux上编译测试?br />因ؓ(f)用VC开发,可以使用VAssist, MetalScroll工具辅助Q开发效率高?br /><br />VC~译通过Qgcc~译仍会(x)有出错?br />用CMake构徏Ӟ~译目录与源码目录是分开的,q样可以在 Linux 上编?Windows ׃n目录下的代码?br />工作目录在Windows上,Linux下编译时Q可以读取Windows下共享的工作目录源码?br />~译时只需d׃n目录下的源码文gQ不需要写׃n目录Q所以编译速度不会(x)下降太多?br /><br />假设W(wng)indows下的工作目录?d:\Game, ׃n?\\192.168.1.2\Game.<br />?Linux ?mount 该共享目录:(x)<br />  mount //192.168.1.2/Game ~/Game -o user=jinqing<br /><br />假设 Linux 上编译目录ؓ(f) ~/build/debug/, 在该目录下运?cmake<br /><span style="color: #000080;">  cmake ~/Game/code -DCMAKE_BUILD_TYPE=Debug</span><br />然后<br /><span style="color: #000080;">  make</span><br />  <br />Win7上共享到 Linux 比较ȝ(ch)Q?因ؓ(f)默认不开理׃nQ需要开几个讄Qƈ修改注册表?br />可参考:(x)Linuxq接至Win7׃n文g?( http://www.examw.com/linux/all/158013/ )<br /><br />需要将2个系l的旉校对下,不然可能不能触发make, 或者时钟警告?br /><br />因ؓ(f)Windows下文件名不区分大写Q所?#include 文g名中大小写错误无法检?br /></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/205948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2014-02-26 11:47 <a href="http://www.shnenglu.com/jinq0123/archive/2014/02/26/205948.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>log4xx/log4j异步日志配置CZhttp://www.shnenglu.com/jinq0123/archive/2013/12/04/204580.html金庆(jin)金庆(jin)Wed, 04 Dec 2013 04:05:00 GMThttp://www.shnenglu.com/jinq0123/archive/2013/12/04/204580.htmlhttp://www.shnenglu.com/jinq0123/comments/204580.htmlhttp://www.shnenglu.com/jinq0123/archive/2013/12/04/204580.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/204580.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/204580.html
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false">

 
<appender name="ROLLING" class="org.apache.log4j.RollingFileAppender">
    
<layout class="org.apache.log4j.PatternLayout">
      
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
    
</layout>
    
<param name="File" value="/var/log/4j/log_gsX.log"/>
    
<param name="MaxFileSize" value="50MB"/>
    
<param name="MaxBackupIndex" value="9"/>
  
</appender>

  
<appender name="DAILY_LUA" class="org.apache.log4j.DailyRollingFileAppender">
    
<layout class="org.apache.log4j.PatternLayout">
      
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
    
</layout>
    
<param name="File" value="/var/log/4j/log_gsX_lua.log"/>
    
<param name="DatePattern" value="'.'yyyy-MM-dd"/>       
  
</appender>

  
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    
<layout class="org.apache.log4j.PatternLayout">
      
<param name="ConversionPattern" value="%d %5p %c %x - %m%n"/>
    
</layout>
    
<param name="Threshold" value="info"/>
  
</appender>
  
  
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
    
<param name="BufferSize" value="100000"/>
    
<param name="Blocking" value="false"/>
    
<appender-ref ref="ROLLING"/>
    
<appender-ref ref="CONSOLE"/>
  
</appender>

  
<appender name="ASYNC_LUA" class="org.apache.log4j.AsyncAppender">
    
<param name="BufferSize" value="100000"/>
    
<param name="Blocking" value="false"/>
    
<appender-ref ref="DAILY_LUA"/>
  
</appender>

  
<root>
    
<level value="info"/>
    
<appender-ref ref="ASYNC" />
  
</root>

  
<logger name="Lua">
    
<level value="info"/> 
    
<appender-ref ref="ASYNC_LUA" />
  
</logger>

  
<logger name="main">
    
<level value="info"/> 
  
</logger>
  
  
<logger name="THSever">
    
<level value="debug"/> 
  
</logger>
</log4j:configuration>

ASYNC异步输出到ROLLING和CONSOLE?/p>

另外QLua日志异步输出为每天一个的独立日志?/p>

默认仅输出INFO日志QTHServer日志c输出DEBUG日志?/p>

CONSOLE屏蔽DEBUG日志?/p>每个服务器用相cM的配|,仅输出文件名不同。可用如下Shell脚本生成各个配置文gQ?br />

for i in {2..32}
do
  sed 
's/gsX/gs'${i}'/g' log4j_gsX.xml > log4j_gs${i}.xml
done


金庆(jin) 2013-12-04 12:05 发表评论
]]>
关于C++E序的编码问?/title><link>http://www.shnenglu.com/jinq0123/archive/2013/11/29/204516.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Fri, 29 Nov 2013 09:08:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2013/11/29/204516.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/204516.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2013/11/29/204516.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/204516.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/204516.html</trackback:ping><description><![CDATA[<div>转自Q?<a >http://blog.chinaunix.net/uid-26790551-id-3190813.html</a><br /><br /> <div style="word-wrap: break-word" class="Blog_wz1"> <div class="jlemvwz" id="preamble"> <div id="uhhamlk" class="sectionbody"> <div id="lpmkrff" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">我们传统的程序基本都只在Windows或只在Linux下运行,W(xu)indowsE序使用?br />中文GB18030~码QLinuxE序则只使用英文Q多q以来这些程序运行v来都没有<br />问题?/font></p></div> <div id="vcythhh" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">q年来,随着E序的组件化Q部分代码特别是公用lg都需要同时支持Windows<br />?qing)Linuxq_Q这样就出现?jin)不同程度的~码问题Q例如在~译时编译器报错Q?br />或者在q行时出Cؕ码。这些问题都和程序选用的字W编码不正确有关?/font></p></div> <p><span id="more-132"><font color="#800080" size="4" face="楷体_GB2312"></font></span></p> <div id="ovgcfyc" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">本文要地分析?jin)C++的一些字W编码问题,q提供了(jin)的方案。受l验和时<br />间的限制Q有些内容可能不一定全面,仅供大家参考?/font></p></div></div></div> <div id="taznnqu" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">1. C++源文件的~码需要特别考虑吗?</font> <div id="uqildaa" class="sectionbody"> <div id="vgompww" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>1.1. 几个相关概念</strong></font> <div id="bqmteti" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">首先要区分几个概念:(x)</font></p></div> <div id="phkyxxm" class="dlist"><font color="#800080" size="4" face="楷体_GB2312">C++源文件的~码 </font> <p><font color="#800080" size="4" face="楷体_GB2312">指的是C++源程序文Ӟ.cpp/.hQ本w用什么字W编码(GB18030/UTF-8{)(j)?</font></p><font color="#800080" size="4" face="楷体_GB2312">C++E序的内?</font> <p><font color="#800080" size="4" face="楷体_GB2312">~译后,C++中的字符串常量都?x)变成一串字节存攑֜可执行文件中。这个内<br />码指的就是在可执行文件中Q字W串以什么编码进行存放。这里的字符串常?br />指的是窄(jing)字符QcharQ而非宽字W(wchar_tQ。宽字符通常是以UnicodeQVC<br />使用UTF-16BEQgcc使用UTF-32BEQ存放?</font></p><font color="#800080" size="4" face="楷体_GB2312">q行环境~码 </font> <p><font color="#800080" size="4" face="楷体_GB2312">指的是执行程序时Q操作系l或l端所使用的编码。程序中输出的字W最l要<br />转换行环境编码才能正显C,否则׃(x)出现q?</font></p></div></div> <div id="uumipei" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>1.2. 各种环境下通常使用的编?/strong></font> <div id="qqpazjy" class="paragraph"> <div id="ffihvgo" class="title"><font color="#800080" size="4" face="楷体_GB2312">C++源文件的~码</font></div> <p><font color="#800080" size="4" face="楷体_GB2312">通常在简体中文Windows环境下,各种~辑器(包括Visual StudioQ新建文件的<br />~省~码都是GB18030Q所以不特别指定的话QW(xu)indows环境下C++源文件的~码<br />通常为GB18030?/font></p></div> <div id="lplookk" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">而在Linux环境下,最怋用,也是推荐使用的是UTF-8~码?/font></p></div> <div id="mtphkzj" class="paragraph"> <div id="yiavrxf" class="title"><font color="#800080" size="4" face="楷体_GB2312">C++E序的内?/font></div> <p><font color="#800080" size="4" face="楷体_GB2312">一般来_(d)我们常用的简体中文版VC所使用的内码是GB18030Q而gcc/g++使用?br />内码~省是utf-8Q但可以通过-fexec-charset参数q行修改?/font></p></div> <div id="ffisyyy" class="admonitionblock"> <table> <tbody> <tr> <td class="icon"> <div id="bfbbxqf" class="title"><font color="#800080" size="4" face="楷体_GB2312">Note</font></div></td> <td class="content"><font color="#800080" size="4" face="楷体_GB2312">可以通过在程序中打印字符串每个字节十六进制Ş式来判断E序所使用的内码?/font></td></tr></tbody></table></div> <div id="pillzoo" class="paragraph"> <div id="wsgjbbu" class="title"><font color="#800080" size="4" face="楷体_GB2312">q行环境~码</font></div> <p><font color="#800080" size="4" face="楷体_GB2312">我们常用的简体中文版Windows的环境编码是GB18030Q而Linux下最常用的环?br />~码是UTF-8?/font></p></div></div> <div id="fjqixqf" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>1.3. q几个编码之间的关系</strong></font> <div id="rrbmeea" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">源程序需要由~译器编译ؓ(f)目标文gQ目标文件运行后输出信息到终端,因此q?br />几个~码之间存在一些的兌Q?/font></p></div> <div id="ibphzcc" class="listingblock"> <div id="tmlzcfq" class="content"><font color="#800080" size="4" face="楷体_GB2312">+--------+ | 源程?|----------源文件编?+---+----+ | ~译器编?+---+----+ |目标文g|----------E序内码 +---+----+ | q行后输Z?+---+----+ | 输出 |----------q行环境~码 +--------+</font></div></div> <div id="delwoow" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">~译器需要正识别源文g的编码,把源文g~译为目标文Ӟq把源文件中<br />的以源文件编码的字符串{换ؓ(f)以程序内码编制的字符串保存在目标文g中?</font></p> <div id="uyufibm" class="admonitionblock"> <table> <tbody> <tr> <td class="icon"> <div id="wpscnny" class="title"><font color="#800080" size="4" face="楷体_GB2312">Note</font></div></td> <td class="content"><font color="#800080" size="4" face="楷体_GB2312">当源文g的字W编码与E序内码都是UTF-8Ӟgcc的缺省情况)(j)Qgccgq不?x)对源文件中的字W编码进行{换,而是直接把字W串原样存放到目标文<br />件中Q在q种情况下,源程序中的GB18030~码的字W串在输出时仍然为GB18030<br />~码。但如果在其它源文g字符~码的实际g~译选项不同Ӟ?x)在~译时报无法从XXX转换到UTF-8的错Q因此还不清楚ؓ(f)什么两个编码都是UTF-8ӞGB18030 ~码的源文g能通过~译?/font></td></tr></tbody></table></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">C++标准库需要正识别终端的q行环境~码Qƈ把程序的输出转换行环<br />境所使用的编码,以便正确昄?</font></p></li></ul></div> <div id="rjbmpte" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">在这q程中,如果有一个环节出现问题,׃(x)DE序的输出发生异常,产生?br />码或其它更严重的后果?/font></p></div></div></div></div> <div id="fqxlzvv" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">2. 源文件应该采用什么编码?</font> <div id="tilhvgr" class="sectionbody"> <div id="cdrnjnc" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>2.1. ~译器对不同源文件编码的支持一样吗Q?/strong></font> <div id="tmxtdkk" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu) </font><a target="_blank"><font color="#800080" size="4" face="楷体_GB2312">http://stackoverflow.com/questions/688760/how-to-create-a-utf-8-string-literal-in-visual-c-2008</font></a><br /><font color="#800080" size="4" face="楷体_GB2312">一文中提供的资料,gcc/vc各版本对C++源文件编码有不同的处理:(x)</font></p></div> <div id="bqqtwwh" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">gcc (v4.3.2 20081105): </font></p> <div id="kdzjuuy" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">支持UTF-8~码的源文gQUTF-8~码的源文g<strong>不能</strong>有BOM?/font></p></div> <div id="fbmxmxq" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu) </font><a target="_blank"><font color="#800080" size="4" face="楷体_GB2312">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33415</font></a><font color="#800080" size="4" face="楷体_GB2312"> Q似乎gcc 4.4.0<br />开始支持带BOM的UTF-8文g?/font></p></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">vc2003: </font></p></li></ul></div> <div id="fnjmbxq" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">支持UTF-8~码的源文gQUTF-8~码的源文g可以有BOMQ也可以没有?/font></p></div> <div id="bthdrrv" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">vc2005+: </font></p></li></ul></div> <div id="rryyfju" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">如果源文件用UTF-8~码的话Q?strong>必须?/strong>BOM?/font></p></div> <div id="osecnrr" class="admonitionblock"> <table> <tbody> <tr> <td class="icon"> <div id="amtaaet" class="title"><font color="#800080" size="4" face="楷体_GB2312">Note</font></div></td> <td class="content"><font color="#800080" size="4" face="楷体_GB2312">gcc提供?finput-charset参数可以指定源文件的字符~码Q但׃标准<br />头文仉是ascii~码的,因此如果要引用标准头文g的话Q源代码的编码必d容ascii。而vc未能扑ֈcM的选项?/font></td></tr></tbody></table></div></div> <div id="fbxhosw" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>2.2. 源文件应该采用什么编码?</strong></font> <div id="cnjtddz" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">很多文章都推荐C/C++代码中只使用ascii字符Q如果有非ascii字符可以用\xHH<br />或\uXXXX表示。注释中使用utf-8~码。也可以使用</font><a target="_blank"><font color="#800080" size="4" face="楷体_GB2312">gettext</font></a><font color="#800080" size="4" face="楷体_GB2312"> 把非ascii字符串放到单独的语言文g中,而在源代码中只保留ascii字符?/font></p></div> <div id="dszcqfj" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">在实践中Q由于\xHH或\uXXXX{方式很不直观,Ҏ(gu)出错且不易发玎ͼ而未必所<br />有程序都需要支持多语言Q因此未必想引入gettext或类似的解决Ҏ(gu)。在q样<br />的情况下Q大安?fn)惯在源E序文g中直接写入中文等非ascii字符Q这需?br />选择一U至能被gcc和vc接受的文件编码?/font></p></div> <div id="lwofixq" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">本来QUnicode是解军_语言问题的最好选择Q而UTF-8׃与ASCII兼容Q也?br />最通用的Unicode~码方式Q但从上面的资料中可见,如果用UTF-8的话QgccQ?br />臛_是低版本Q不允许有BOMQ而vc2005 以上要求必须有BOMQ因此同一个文?br />无法在gcc?qing)vc下通过~译QUTF-8g不是一个好的选择。但如果使用gcc比较<br />高的版本Q?.4.0以上Q)(j)Q用带BOM的UTF-8~码文g应该也是可行的?/font></p></div> <div id="crqmtxm" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">考虑到目前现Ӟ我们一般都在简体中文Windows下工作,源文件中使用GB18030<br />~码g是一个比较现实的选择。在vc下可以直接编译,而在gcc下也可以通过<br />增加~译选项-finput-charset=gb18030予以支持。而且Ҏ(gu)l基癄中GB18030<br />的词条内容,GB18030 is a superset of ASCII and can represent the whole<br />range of Unicode code pointsQGB18030向后兼容ASCIIQƈ且能表示所有的<br />Unicode码点Q,因此使用GB18030有够的表达能力Q可以表C所有的Unicode<br />字符。用GB18030的唯一~点是在非体中文版本的VC下,׃无法指定?br />文g的编码,因此有可能无法正识别此~码的源文g?/font></p></div></div></div></div> <div id="txasgvv" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">3. 应该使用什么程序内码?</font> <div id="hdrxewh" class="sectionbody"> <div id="mbiewwd" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">正如前面提到的,C++有窄(jing)字符QcharQ和宽字W(wchar_tQ的分别Q分别有一<br />套相应的cd函数Qstring/cout/strlen与wstring/wcout/wcslen{)(j)。前者在<br />不同的编译器下有不同的缺省编码(体中文vc是GB18030Qgcc是UTF-8Q,?br />者一般都使用UnicodeQ其中vc下用UTF-16Qgcc~省使用UTF-32?/font></p></div> <div id="padgjnc" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">C++在输出窄(jing)字符时会(x)按程序内码原栯出,不会(x)q行~码转换Q因此在使用H?br />字符时要求程序内码与q行环境~码一_(d)q样才不?x)出Cؕ码。由于简体中?br />版vc的程序内码是GB18030Q因此用窄(jing)字符的vcE序只能q行在GB18030环境?br />。同P׃gcc~省使用UTF-8作ؓ(f)E序内码Q因此用窄(jing)字符的gccE序只能<br />q行在UTF-8的终端环境下。(q里说的都是在源代码中直接写中文{非ascii?br />W的E序。用前面提到的gettext?qing)其它工P使用H字W的E序也可以在不同<br />~码的运行环境中正确输出中文Q?/font></p></div> <div id="hahvyyy" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">C++在输出宽字符时会(x)自动转换行环境的~码Q因此只要正设|了(jin)q行?br />境编码,同一个程序就可以在不同编码的q行环境中正显CZ文。这一点与<br />Java/.Net很象QJava/.Net的字W串cd都用UnicodeQ在输入/输出旉需?br />与当前运行环境的~码q行互{?/font></p></div> <div id="tihkycc" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">一般来_(d)如果需要支持多语言Q有两种比较好的做法Q?/font></p></div> <div id="mfmielz" class="olist arabic"> <ol class="arabic"><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,但源E序中只使用ascii字符Q非ascii字符通过gettext或其?br />工具攑ֈ单独的文件中Q由gettext{工具处理编码{换的问题?</font></p> <div id="gkrnmff" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">在各U编码的q行环境中均能正输Z文?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">E序中不能直接出现非ascii字符Q也不能通过\uXXXX方式指定非ascii字符Q后者也?x)被~译器{换ؓ(f)非ascii字符q存攑֜目标文g中?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">注释中可以用ascii兼容的编码,不媄(jing)响编译器?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">有比较多的现成代码可供重用?</font></p></li></ul></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用宽字W?</font></p> <div id="emlhgvg" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">在各U编码的q行环境中均能正输Z文?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">E序中可以用非ascii字符?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">需要配合前面的源程序文件编码设|,让编译器能正识别源E序中的?br />ascii字符?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">׃以前使用宽字W的E序比较?yu),可供重用的代码较(yu)?</font></p></li></ul></div></li></ol></div> <div id="bxpogcj" class="admonitionblock"> <table> <tbody> <tr> <td class="icon"> <div id="vggyfrn" class="title"><font color="#800080" size="4" face="楷体_GB2312">Note</font></div></td> <td class="content"><font color="#800080" size="4" face="楷体_GB2312">如果E序中需要一些固定字W编码的字符串常量,例如固定是GB18030<br />~码的字W串帔RQ这些常量应该以\xXX的方式存攑֭W串帔RlGB18030~码后的内容Q这L(fng)内容才不?x)被转换为程序的内码Q也不会(x)转换行环境编码?/font></td></tr></tbody></table></div></div></div> <div id="xftlodk" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">4. q行环境应该用什么字W编码?</font> <div id="grvjqfn" class="sectionbody"> <div id="gzvgycg" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">正如上面提到的,使用H字W和使用宽字W的E序对运行环境的字符~码要求?br />不一L(fng)?/font></p></div> <div id="vgyqtbf" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用宽字W,只要在程序中正确讄当前环境的字W编码(一般通过locale::global(locale("")) q行讄Q,C++标准库会(x)在输入、输出时?br />进行字W编码{换,因此可以适应各种~码的运行环境?/font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,但程序中不出现非ascii字符的话Q对q行环境没有特别要求Q?br />可以适应各种~码的运行环境?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,E序中也直接使用汉字{非ascii字符的话Q由于C++标准库会(x)?br />目标文g中保存的字符Ԍ以程序内码保存)(j)直接输出Q不?x)进行字W编码{换,因此要求q行环境的编码与E序内码一致。即体中文VC~译的程序只能运行在GB18030环境下,gcc~译的程序只能运行在UTF-8环境下(可以在编译时通过-fexec-charset参数q行修改Q?</font></p></li></ul></div></div></div> <div id="qxelskd" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">5. C++源文件编码的选择</font> <div id="ttelkzd" class="sectionbody"> <div id="nvgjfqq" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>5.1. 几种可行做法</strong></font> <div id="bqbewtb" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu)上面的讨论,目前看来Q要兼容Windows/LinuxQVC/gcc的话Q有几种做法<br />Q?/font></p></div> <div id="sthvnyq" class="olist arabic"> <ol class="arabic"><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序中只用ascii字符Q非ascii字符Q如中文{通过<br />gettext{工h到单独的语言包中?</font></p> <div id="qknuunj" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">q种做法比较多h推荐?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容VC?qing)gcc各版本?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">׃源程序中不出现非ascii字符Q因此不需要考虑源程序文件的~码问题?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容各种~码的运行环境?</font></p></li></ul></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序中允许使用非ascii字符?</font></p> <div id="crnnbif" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">要求q行环境的编码与E序内码一_(d)卛_支持GB18030~码的Windows?br />UTF-8~码的Linux?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu)源程序用的~码不同Q对~译器的兼容性也不同Q?</font></p> <div id="xbelwwa" class="olist loweralpha"> <ol class="loweralpha"><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序用带BOM的UTF-8~码?</font></p> <div id="etpzgvr" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容VC各语U的各版本?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容gcc 4.4.0以上版本?</font></p></li></ul></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序用GB18030~码?</font></p> <div id="eilhkss" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容VC的简体中文各版本?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容gcc各版本,但在~译旉要加?finput-char=gb18030参数?</font></p></li></ul></div></li></ol></div></li></ul></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用宽字W,源程序中允许使用非ascii字符?</font></p> <div id="vszgync" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容各种~码的运行环境?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu)源程序用的~码不同Q对~译器的兼容性也不同Q?</font></p> <div id="ixplokz" class="olist loweralpha"> <ol class="loweralpha"><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序用带BOM的UTF-8~码?</font></p> <div id="dszzrvd" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容VC各语U的各版本?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容gcc 4.4.0以上版本?</font></p></li></ul></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">使用H字W,源程序用GB18030~码?</font></p> <div id="ttlkngg" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容VC的简体中文各版本?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">兼容gcc各版本,但在~译旉要加?finput-char=gb18030参数?</font></p></li></ul></div></li></ol></div></li></ul></div></li></ol></div></div> <div id="lbpkkkk" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>5.2. 推荐做法</strong></font> <div id="bbthzdl" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">Ҏ(gu)我们的现Ӟ对于需要支持多语种的程序,使用H字W,源程序中只<br />用ascii字符?/font></p></div> <div id="leaddwa" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">对于不需要支持多语种的程序,考虑到重用已有的代码Q可以考虑使用H字W,<br />采用GB18030~码Q但只能q行在GB18030~码的Windows环境?qing)UTF-8~码?br />Linux环境下?/font></p></div></div></div></div> <div id="iisgfuf" class="sect1"><font color="#800080" size="4" face="楷体_GB2312">6. 其它问题</font> <div id="delocnj" class="sectionbody"> <div id="vssokzo" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>6.1. 用户输入、输出及(qing)持久?/strong></font> <div id="eqmahsd" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">׃用户输入、输出及(qing)从文件、网l等设施d的数据在E序底层看来都是字节<br />,因此存在在输入时如何把这些字节流解释成有效的信息Q在输出时怎么把程<br />序中的信息{换ؓ(f)正确的字节流的问题?/font></p></div> <div id="itwhzko" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">如果E序本n不需要处理这些数据,只是把数据从一个来源搬到另一个地方(<br />如把用户输入保存到文Ӟ或者从一个流dQ写到另一个流{)(j)Q而输入的字符~码与输出的字符~码一致的话,E序不需要对数据q行M~码转换Q只需要把d的数据按原样写到输出卛_Q数据的字符~码与程序的~码没有关系?</font></p> <div id="xqxiebb" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">比如|站应用E序Q只需要保证用户页面用UTF-8~码Q数据库、数据文件也都用UTF-8~码Q那么用戯入的数据可以直接写入数据库及(qing)数据文gQ从数据库或数据文g中读取的数据也可以直接展现给用户Q不需要进行编码{换?/font></p></div></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">如果E序需要在一定程序上Ҏ(gu)据进行处理(如需要判断字W个数、对字符q?br />行比较、在字符串上附加或去掉内容)(j)Q就要把数据转换ZU明的字符~码Q一般来说是E序内码Q再q行处理Q在处理后再转换为所需的字W编码进行输出?</font></p> <div id="etpdzgv" class="ulist"> <ul><li> <p><font color="#800080" size="4" face="楷体_GB2312">对于宽字W程序,如果只需要处理采用当前运行环境字W编码的数据Q可以通过ios::imbue()可以指定io的字符~码Q在输入、输出时C++标准库会(x)自动在所指定的字W编码与E序内码之间q行~码转换。如果不使用的话,也可以通过标准的wcstombs()或mbstowcs()函数q行当前~码Q通过locale::global()或setlocale()指定Q与宽字W之间的转换?/font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">对于H字W程序,如果数据的字W编码与E序内码一致也不需要进行编码{换,直接处理卛_?</font></p></li><li> <p><font color="#800080" size="4" face="楷体_GB2312">对于其它情ŞQ需要引入iconv或类似的字符~码转换库,以便实现不同<br />字符~码之间的{换?</font></p></li></ul></div></li></ul></div></div> <div id="kszvnvv" class="sect2"><font color="#800080" face="楷体_GB2312"><strong>6.2. gettext、iconv的替代品</strong></font> <div id="ixelskv" class="paragraph"> <p><font color="#800080" size="4" face="楷体_GB2312">׃gettext?qing)iconv都属于GNU ProjectQ考虑到版权因素,q所有程序,特别是商业程序,都适合使用q些库。在Boost 1.48.0中,Boost.Locale库首ơ正式发布,该库提供?jin)gettext、iconv的功能,q在此基上进行了(jin)增强Q提供了(jin)大小写变换、字W顺序比较、时间的处理 、分词、数字的格式化输?输出、消息格式化、多语种支持、字W编码{换等功能Q值得q一步研I及(qing)使用?/font></p></div></div></div></div></div></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/204516.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2013-11-29 17:08 <a href="http://www.shnenglu.com/jinq0123/archive/2013/11/29/204516.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CMaked-D_DEBUG?http://www.shnenglu.com/jinq0123/archive/2013/07/26/202141.html金庆(jin)金庆(jin)Fri, 26 Jul 2013 08:33:00 GMThttp://www.shnenglu.com/jinq0123/archive/2013/07/26/202141.htmlhttp://www.shnenglu.com/jinq0123/comments/202141.htmlhttp://www.shnenglu.com/jinq0123/archive/2013/07/26/202141.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/202141.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/202141.html

Linux下Debug版不?x)自动添?_DEBUG宏,只有NDEBUG宏可用?/p>


cmake ../src _DCMAKE_BUILD_TYPE=Debug -D_DEBUG

?x)报错?x) -D_DEBUG should be: VAR:type=value

需?D_DEBUG=1.


改ؓ(f)在CMakeLists.txt中添加:(x)

if (CMAKE_BUILD_TYPE STREQUAL Debug)

    add_definitions(

        -D_DEBUG

    )

endif ()




金庆(jin) 2013-07-26 16:33 发表评论
]]>
Win7讉KRedhat samba׃nhttp://www.shnenglu.com/jinq0123/archive/2012/09/17/190955.html金庆(jin)金庆(jin)Mon, 17 Sep 2012 03:37:00 GMThttp://www.shnenglu.com/jinq0123/archive/2012/09/17/190955.htmlhttp://www.shnenglu.com/jinq0123/comments/190955.htmlhttp://www.shnenglu.com/jinq0123/archive/2012/09/17/190955.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/190955.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/190955.html

Win7讉KRedhat samba׃n

首先是开启samba:

service smb start

service smb restart

samba的配|文件是/ect/samba/smb.conf, 几乎不用改,使用默认配置p?jin)?/p>

默认是?security=user 模式׃nQ需要输入用户名密码才能讉K?/p>

默认有[homes]׃n配置Q各个用户可讉K自己的主目录?/p>

如添加新用户Q?/p>

useradd jinqing

passwd jinqing

smbpasswd -a jinqing

smb需要自q用户密码Q需用smbpasswd讄?/p>

q样共享了(jin)/home/jinqing.

试Qsmbclient //localhost/jinqing -Ujinqing

需要设|Selinux参数Q以允许׃n讉KQ可参照smb.conf中的注释q行Q?/p>

setsebool -P samba_enable_home_dirs on


然后是win7需要设|安全策略,不然也会(x)q不上?br />

打开理工具Q?#8220;本地{略”->“安全选项”->“|络安全QLAN Manager w䆾验证U别”Q?br />单击列表中:(x)发送LM和NTLMv2Q如果已协商Q则使用NTLMv2协议?br />




金庆(jin) 2012-09-17 11:37 发表评论
]]>
CMake生成版本?/title><link>http://www.shnenglu.com/jinq0123/archive/2012/08/15/187268.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Wed, 15 Aug 2012 04:30:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2012/08/15/187268.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/187268.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2012/08/15/187268.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/187268.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/187268.html</trackback:ping><description><![CDATA[<div>CMake生成版本?br /><br />Q金?jin)的专栏Q?br /><br />原来的CMake需要用shell脚本生成SVN版本P再作为cmake参数传入?br /><br />CMake调用脚本CZQ?br /><br /><span style="font-family:Courier New;color:#660000;">#!/bin/sh<br /># cmake.sh<br /><br />ServerCodeRoot=~/Code/Server<br />CodeRevNum=`svn info ${ServerCodeRoot} | grep Revision | awk -F' ' '{ print $2 }'`<br />cmake S{ServerCodeRoot} -DCMAKE_BUILD_TYPE=Release -DVERSION_REVISION=S{CodeRevNum}<br /></span><br />CMakeLists.txt中如下配|:(x)<br /><span style="font-family:Courier New;color:#660000;">configure_file(<br />  "Version.h.in"<br />  "Version.h"<br />)</span><br /><br />Version.h.in如下Q?br /><br /><span style="font-family:Courier New;color:#660000;">#include <string><br />const std::string VERSION_MAJOY("1");<br />const std::string VERSION_MINOR("0");<br />const std::string VERSION_REVISION("@VERSION_REVISION@");<br /></span><br />Linux下执行cmake.sh?x)自动替换SVN版本受?br /><br />现改为用FIND_PACKAGE(Subversion)方式Q不必用shell脚本生成SVN版本P<br />q且在Windows上也可以生成版本? cmake调用时不必传VERSION_REVISION参数?br /><br />CMakeLists.txt改ؓ(f)Q参考了(jin)开源网游ryzom的CMakeQ:(x)<br /><br /><span style="font-family:Courier New;color:#660000;">SET(ROOT_DIR ${PROJECT_SOURCE_DIR})<br />IF(EXISTS "${ROOT_DIR}/.svn/")<br />  FIND_PACKAGE(Subversion)<br /><br />  IF(SUBVERSION_FOUND)<br />    Subversion_WC_INFO(${ROOT_DIR} Project)<br />    SET(VERSION_REVISION ${Project_WC_REVISION})<br />  ENDIF(SUBVERSION_FOUND)<br />ENDIF(EXISTS "${ROOT_DIR}/.svn/")<br /><br />CONFIGURE_FILE(<br />  "Version.h.in"<br />  "Version.h"<br />)</span><br /><br />如果不是SVN, 而是用Hg, 可用如下脚本Q?br /><span style="font-family:Courier New;color:#660000;">IF(EXISTS "${ROOT_DIR}/.hg/")<br />  FIND_PACKAGE(Mercurial)<br /><br />  IF(MERCURIAL_FOUND)<br />    Mercurial_WC_INFO(${ROOT_DIR} ER)<br />    SET(REVISION ${ER_WC_REVISION})<br />    SET(CHANGESET ${ER_WC_CHANGESET})<br />    SET(BRANCH ${ER_WC_BRANCH})<br />  ENDIF(MERCURIAL_FOUND)<br />ENDIF(EXISTS "${ROOT_DIR}/.hg/")<br /></span></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/187268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2012-08-15 12:30 <a href="http://www.shnenglu.com/jinq0123/archive/2012/08/15/187268.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多线E开启gprof性能试的简易方?http://www.shnenglu.com/jinq0123/archive/2012/08/01/185908.html金庆(jin)金庆(jin)Wed, 01 Aug 2012 08:23:00 GMThttp://www.shnenglu.com/jinq0123/archive/2012/08/01/185908.htmlhttp://www.shnenglu.com/jinq0123/comments/185908.htmlhttp://www.shnenglu.com/jinq0123/archive/2012/08/01/185908.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/185908.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/185908.html

多线E开启gprof性能试的简易方?/div>
Q金?jin)的专栏Q?/div>

用到gprof时才知道Q原来gprof只能对主U程l计耗时。manual上也没写U程相关的问题啊Q?/p>

不过有现成的解决Ҏ(gu)Qhttp://sam.zoy.org/writings/programming/gprof.html

该方案封装了(jin)pthread_create(), 让线E初始化执行一个setitimer(ITIMER_PROF, ...)?/p>

易的Ҏ(gu)是直接在代码中写个setitimer()?/p>

  1. #include <sys/time.h>  
  2. #include <boost/thread.hpp>  
  3.   
  4. struct itimerval g_itimer;  
  5.   
  6. void foo()  
  7. {  
  8.     setitimer(ITIMER_PROF, &g_itimer, NULL);  
  9.     for (int i = 0; i < 10000000; i++)  
  10.         (void)i;  
  11. }  
  12.   
  13. int main()  
  14. {  
  15.     getitimer(ITIMER_PROF, &g_itimer);  
  16.     boost::thread t(&foo);  
  17.     t.join();  
  18.     return 0;  
  19. }  

g++ main.cpp -pg -lboost_thread

./a.out

gprof

q样pl计出foo()的耗时?jin)。没有setitimer()׃?x)有foo()的耗时l计?/p>




金庆(jin) 2012-08-01 16:23 发表评论
]]>MySql的CMake选项支持gcov和gprof http://www.shnenglu.com/jinq0123/archive/2012/07/11/182807.html金庆(jin)金庆(jin)Wed, 11 Jul 2012 04:15:00 GMThttp://www.shnenglu.com/jinq0123/archive/2012/07/11/182807.htmlhttp://www.shnenglu.com/jinq0123/comments/182807.htmlhttp://www.shnenglu.com/jinq0123/archive/2012/07/11/182807.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/182807.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/182807.html

未来的MySql 5.6.6 中,CMake选项中添加了(jin)gprof性能试支持Q见Q?br />

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html


ENABLE_GPROF     Enable gprof (optimized Linux builds only)     OFF     5.6.6     


代码库中的CMakeLists.txt 摘录如下Q?/p>

  1. OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)  
  2. IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)  
  3.   SET(CMAKE_CXX_FLAGS_DEBUG  
  4.     "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")  
  5.   SET(CMAKE_C_FLAGS_DEBUG  
  6.     "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")  
  7.   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG  
  8.     "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov")  
  9. ENDIF()  
  10.   
  11. OPTION(ENABLE_GPROF "Enable gprof (optimized, Linux builds only)" OFF)  
  12. IF (ENABLE_GPROF AND NOT WIN32 AND NOT APPLE)  
  13.   SET(CMAKE_C_FLAGS_RELWITHDEBINFO  
  14.     "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg")  
  15.   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO  
  16.     "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg")  
  17.   SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO  
  18.     "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -pg")  
  19. ENDIF()  


金庆(jin) 2012-07-11 12:15 发表评论
]]>
CMakedgcov代码覆盖试支持 http://www.shnenglu.com/jinq0123/archive/2012/07/11/182790.html金庆(jin)金庆(jin)Wed, 11 Jul 2012 03:11:00 GMThttp://www.shnenglu.com/jinq0123/archive/2012/07/11/182790.htmlhttp://www.shnenglu.com/jinq0123/comments/182790.htmlhttp://www.shnenglu.com/jinq0123/archive/2012/07/11/182790.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/182790.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/182790.html

CMakedgcov代码覆盖试支持

Q金?jin)的专栏Q?/p>

在根CMakeList.txt中添加ENABLE_GCOV选项Q?br />

OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)

IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
  SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov")
ENDIF()


以上代码来自MySQL的CMakeLists.txt.

如下执行cmake:

cmake SRC_DIR -DCMAKE_BUILD_TYPE=Debug -DENABLE_GCOV=1


~译后就可以看到图文?*.gcno?/p>

q行后,可以看到数据文g*.gcda生成?/p>执行 gcov main.cpp.gcno q?main.cpp.gcov 试l果?/div>

金庆(jin) 2012-07-11 11:11 发表评论
]]>
CMake区分debug、release版本http://www.shnenglu.com/jinq0123/archive/2012/03/27/169143.html金庆(jin)金庆(jin)Tue, 27 Mar 2012 05:56:00 GMThttp://www.shnenglu.com/jinq0123/archive/2012/03/27/169143.htmlhttp://www.shnenglu.com/jinq0123/comments/169143.htmlhttp://www.shnenglu.com/jinq0123/archive/2012/03/27/169143.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/169143.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/169143.html

摘自Q?http://www.shnenglu.com/tx7do/archive/2010/08/19/124000.html


建立debug/release两目录,分别在其中执行cmake -DCMAKE_BUILD_TYPE=DebugQ或ReleaseQ,需要编译不同版本时q入不同目录执行make卛_Q?/p>

Debug版会(x)使用参数-gQRelease版?O3 –DNDEBUG



金庆(jin) 2012-03-27 13:56 发表评论
]]>
建立Socket Policy服务?/title><link>http://www.shnenglu.com/jinq0123/archive/2012/01/19/164375.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Thu, 19 Jan 2012 08:21:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2012/01/19/164375.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/164375.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2012/01/19/164375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/164375.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/164375.html</trackback:ping><description><![CDATA[<div>建立Socket Policy服务?br /><br />Q金?jin)的专栏Q?br /><br />Flash和Unity3D游戏服务器需要开启一个Socket Policy服务器?br />详细说明见:(x)Setting up a socket policy file server<br />http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html<br /><br />协议如下Q?br />Flash或U3D播放器向Socket Policy服务器发送请求:(x)<br />“<policy-file-request/>\0”Q?br />服务器返回一个xml文本Q其中有包含<cross-domain-policy>配置?br /><br />Adobe提供?jin)Perl和Python代码。Unity3D提供?jin)CSharp代码?br />cs代码用于Windows. Linux上准备用Python代码?br />在以上网下载:(x)flashpolicyd_v0.6.zip?br />其中?个版本:(x)init服务Qxinetd服务Q独立应用。只需一U即可?br /><br />按应用的性质Q请求量极小Q所以最适合应用xinetd.<br />只需q行其中的install.sh׃(x)安装?br />q需手工?ect/services中添加服务名flashpolicy和端?43.<br /><br />q行以下指o(h)可以试一下,输出应该是配|文件的内容?br />python -c 'print "<policy-file-request/>%c" % 0' | nc 127.0.0.1 843<br /><br />其实以上试指o(h)在尾部多?jin)?\n', 不是标准的测试?br />在in.flashpolicyd.py中多?jin)个strip()去除q个'\n'.<br /><br />实际用U3D试Ӟ因ؓ(f)没有'\n'l尾Q所以in.flashpolicyd.py无法正常工作?br />需要将35行readline()如下更改Q?br />        request = sys.stdin.readline().strip()<br />改ؓ(f)<br />        request = sys.stdin.readline(len('<policy-file-request/>\0')).strip()<br />q样׃需要eol可以读取了(jin)?br /><br />查看其他两个版本的代码没有这个错误,但是有另一个错误,<br />x可能只读一半的h造成判断出错?br /><br />q有一个问题是因ؓ(f)服务是由nobodyq行的,环境变量不同Q?br />in.flashpolicyd.py头部?br />#!/usr/bin/env python<br />明确?br />#!/usr/local/sbin/python<br />可避免调用低版本的python而报错?br /></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/164375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2012-01-19 16:21 <a href="http://www.shnenglu.com/jinq0123/archive/2012/01/19/164375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL无法本地q接http://www.shnenglu.com/jinq0123/archive/2011/10/21/158831.html金庆(jin)金庆(jin)Fri, 21 Oct 2011 08:27:00 GMThttp://www.shnenglu.com/jinq0123/archive/2011/10/21/158831.htmlhttp://www.shnenglu.com/jinq0123/comments/158831.htmlhttp://www.shnenglu.com/jinq0123/archive/2011/10/21/158831.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/158831.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/158831.htmlMySQL无法本地q接

Q金?jin)的专栏Q?br />
Linux重启后,发现不知怎么的MySQL无法本地q接?br />
l果phpMyAdmin, Zentao都无法正常工作了(jin)?br />
q程的连接用?jin)TCP是正常的Q本地连接用?jin)本地socket, 有问题?br />
本地q行mysql客户端会(x)报错Q?br />Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

重启mysql服务也报错:(x)
# service mysql restart
MySQL server PID file could not be found!
Starting MySQL... ...The server quit without updating PID file (/var/lib/mysql/localhost/localdomain.pid)

?pid文g不存在。所以无法关闭mysql. 正在q行的mysql服务一直无法关闭?br />
参考:(x)http://zhujipi.com/vps/109.html
说明QMysql的进E卡M(jin)Q这时用p把这些卡ȝq程都关闭?br />
mysql服务重启成功后恢复正常?br />

金庆(jin) 2011-10-21 16:27 发表评论
]]>
讑֮“svn:needs-lock”属?/title><link>http://www.shnenglu.com/jinq0123/archive/2011/10/12/158128.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Wed, 12 Oct 2011 06:33:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2011/10/12/158128.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/158128.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2011/10/12/158128.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/158128.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/158128.html</trackback:ping><description><![CDATA[<div><p>摘自Q?http://www.cnblogs.com/LittleFox/archive/2009/04/08/1431781.html</p><p><br /></p><p><span id="comment_body_1498206">讑֮“svn:needs-lock”属?br />使用命o(h)行锁?#8220;介绍.doc”Q?br /><br />svn propset svn:needs-lock 'x' 介绍.doc<br /><br />q?行这个命令后Q?#8220;介绍.doc”已l是讄?#8220;svn:needs-lock ”Q但Z(jin)使之生效q要q行“svn commit”Q之后其他用户update的时候就?x)发现这个文件已l是只读的了(jin)。需要注意的是我们设|的属性值是“x”Q实际上L值都可以Q? Subversion?x)忽略其内容?br /><br />使用TortoiseSVN讑֮属性也很简单:(x)<br /><br />“介绍.doc”右键选中- >属?>Subversion选项?>properties->addQ然后在弹出的窗口中的property name选择“svn:needs-lock”QgQ意,然后选择OK。之后再提交“介绍.doc”卛_?/span><br /></p></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/158128.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2011-10-12 14:33 <a href="http://www.shnenglu.com/jinq0123/archive/2011/10/12/158128.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决 undefined symbol: php_ini_scanned_fileshttp://www.shnenglu.com/jinq0123/archive/2011/09/26/156861.html金庆(jin)金庆(jin)Mon, 26 Sep 2011 08:25:00 GMThttp://www.shnenglu.com/jinq0123/archive/2011/09/26/156861.htmlhttp://www.shnenglu.com/jinq0123/comments/156861.htmlhttp://www.shnenglu.com/jinq0123/archive/2011/09/26/156861.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/156861.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/156861.htmlapache加蝲php时出错:(x)
Starting httpd: httpd: Syntax error on line 57 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: undefined symbol: php_ini_scanned_files

|上搜烦(ch)的所有方法都没有解决q个错误?/p>

最后make clean;make;make install好?jin)?/p>

估计是需要make clean清除上次的错误才行?/p>




金庆(jin) 2011-09-26 16:25 发表评论
]]>
预编译输出的行标?/title><link>http://www.shnenglu.com/jinq0123/archive/2010/09/15/126636.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Wed, 15 Sep 2010 02:53:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2010/09/15/126636.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/126636.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2010/09/15/126636.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/126636.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/126636.html</trackback:ping><description><![CDATA[     摘要: 调用预编译器cpp预编译main.cpp生成main.i文gQ?<br> $cpp main.cpp > main.i <br>或者:(x) <br> $gcc -E main.cpp > main.i <br> <br>生成的行h志中有如下格式的Q?<br> # 1 ?usr/include/features.h?1 3 4  <a href='http://www.shnenglu.com/jinq0123/archive/2010/09/15/126636.html'>阅读全文</a><img src ="http://www.shnenglu.com/jinq0123/aggbug/126636.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2010-09-15 10:53 <a href="http://www.shnenglu.com/jinq0123/archive/2010/09/15/126636.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vi查看制表W?/title><link>http://www.shnenglu.com/jinq0123/archive/2010/05/17/115584.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Mon, 17 May 2010 06:21:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2010/05/17/115584.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/115584.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2010/05/17/115584.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/115584.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/115584.html</trackback:ping><description><![CDATA[     摘要: 在VC中编?>高菜单中有个“查看空白”,我L打开的?<br>在VI中,也有cM功能Q可以查看TAB?qing)行根{?nbsp; <a href='http://www.shnenglu.com/jinq0123/archive/2010/05/17/115584.html'>阅读全文</a><img src ="http://www.shnenglu.com/jinq0123/aggbug/115584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2010-05-17 14:21 <a href="http://www.shnenglu.com/jinq0123/archive/2010/05/17/115584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cygwin与MinGW的区?/title><link>http://www.shnenglu.com/jinq0123/archive/2010/03/29/110795.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Mon, 29 Mar 2010 02:25:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2010/03/29/110795.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/110795.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2010/03/29/110795.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/110795.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/110795.html</trackback:ping><description><![CDATA[     摘要: 跟Cygwin相比Q最大的区别是其采用的不?GNU的libc库,而是Windows下的cq行时库mscvrt?nbsp; <a href='http://www.shnenglu.com/jinq0123/archive/2010/03/29/110795.html'>阅读全文</a><img src ="http://www.shnenglu.com/jinq0123/aggbug/110795.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2010-03-29 10:25 <a href="http://www.shnenglu.com/jinq0123/archive/2010/03/29/110795.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>当心(j)虚函数重?overloaded-virtual)http://www.shnenglu.com/jinq0123/archive/2009/05/22/85378.html金庆(jin)金庆(jin)Fri, 22 May 2009 05:59:00 GMThttp://www.shnenglu.com/jinq0123/archive/2009/05/22/85378.htmlhttp://www.shnenglu.com/jinq0123/comments/85378.htmlhttp://www.shnenglu.com/jinq0123/archive/2009/05/22/85378.html#Feedback4http://www.shnenglu.com/jinq0123/comments/commentRss/85378.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/85378.html
Q{载请注明来源于金?jin)的专栏Q?br>
为网怸王之?(KOK3)服务器添加新功能的时?
发现某个cL员函数应该是const函数, 因ؓ(f)我的const函数要调用该函数,
手加上了(jin)const.

再顺便看到该cL好多个明显是getter函数, 所以都加上?jin)const.
~译没错提交了(jin).

l果没多久测试就发现?jin)新版本的一个错? 表现在其他功能上,
但由同事U错后发现是我添加const的后?

原来dconst的成员函C, 有一个是virtual函数, 加了(jin)const后与子类的函数原型就不符?
子类的函数成为父c虚函数的一个重? 使virtual失效, 多态性无法表现出?
解决Ҏ(gu)是子类的相应虚函数中也dconst.

教训: 更改虚函数原型时, 必须同时更改父类和子c?

gcc中有?Woverloaded-virtual警告选项, ?x)报告这U虚函数重蝲.

我在Makefile中打开?Woverloaded-virtual, 再次~译时就产生?jin)许多警?
大多数警告是正确的函数重? 但还是发C(jin)一个与我相同的错误,
q次是函数参数const有区? 我发l相关h员处理了(jin).

因ؓ(f)开?Werror, 所有警告都?x)造成~译p|,
所以我们不能在Makefile中加?Woverloaded-virtual警告选项.

代码CZ:

class A
{
    virtual void f() {};
};

class B : public A
{
    virtual void f() const {};
};

int main()
{
    return 0;
}

$ g++ main.cpp -Woverloaded-virtual
main.cpp:3: warning: `virtual void A::f()' was hidden
main.cpp:8: warning:   by `virtual void B::f() const'

Google的代码规范中要求所有子cȝ虚函C都加上virtual, 是很有道理的.
虽然只要与父c虚函数{֐相同, 加不加virtual都是虚函?
但是以后更改函数{֐? 看到virtual很容易知道它是虚函数, 需要父cdcd时更?




金庆(jin) 2009-05-22 13:59 发表评论
]]>
pthread_rwlock使用错误http://www.shnenglu.com/jinq0123/archive/2008/11/14/pthread_rwlock_abuse.html金庆(jin)金庆(jin)Fri, 14 Nov 2008 02:47:00 GMThttp://www.shnenglu.com/jinq0123/archive/2008/11/14/pthread_rwlock_abuse.htmlhttp://www.shnenglu.com/jinq0123/comments/66884.htmlhttp://www.shnenglu.com/jinq0123/archive/2008/11/14/pthread_rwlock_abuse.html#Feedback1http://www.shnenglu.com/jinq0123/comments/commentRss/66884.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/66884.html  阅读全文

金庆(jin) 2008-11-14 10:47 发表评论
]]>
UNIX 技?/title><link>http://www.shnenglu.com/jinq0123/archive/2008/07/30/UnixTricks.html</link><dc:creator>金庆(jin)</dc:creator><author>金庆(jin)</author><pubDate>Wed, 30 Jul 2008 01:00:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2008/07/30/UnixTricks.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/57488.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2008/07/30/UnixTricks.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/57488.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/57488.html</trackback:ping><description><![CDATA[     摘要: <br>* 利用位置变量 $0 昄Shell?<br>* bash中输入一半文件名Q用TAB键自动补?<br>* ! 历史扩展 <br>* ?pushd ?popd 在目录树(wi)中导?<br>* 查找大于 10MB 的所有文?<br>  <a href='http://www.shnenglu.com/jinq0123/archive/2008/07/30/UnixTricks.html'>阅读全文</a><img src ="http://www.shnenglu.com/jinq0123/aggbug/57488.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">金庆(jin)</a> 2008-07-30 09:00 <a href="http://www.shnenglu.com/jinq0123/archive/2008/07/30/UnixTricks.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Unix~程哲学http://www.shnenglu.com/jinq0123/archive/2007/08/29/UnixPhilosophy.html金庆(jin)金庆(jin)Wed, 29 Aug 2007 07:32:00 GMThttp://www.shnenglu.com/jinq0123/archive/2007/08/29/UnixPhilosophy.htmlhttp://www.shnenglu.com/jinq0123/comments/31159.htmlhttp://www.shnenglu.com/jinq0123/archive/2007/08/29/UnixPhilosophy.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/31159.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/31159.html  阅读全文

金庆(jin) 2007-08-29 15:32 发表评论
]]>
þþƷAVDz18| ũ帾ŮëƬƷþ| ƷëٸAVѾþ| þóСƵ| 뾫Ʒþþþþ| þþƷAV| ҹѸþӰԺ| ۲ӰԺþùƷ| þþƷ99þ˿| 㽶99þùۺϾƷլ | ˳ŷþ| þþƷAVӰԺ| þþþ޾Ʒһ| ˶ݺɫۺϾþ| ձձȾþþƷ| AVþþƷ| þþƷ99Ӱ| þþѹ۳ӰԺ| ޳ɫwwwþվҹ| 88þþƷһëƬ| þۺϾþۺ| 97þþþ޾Ʒר| ޹ƷۺϾþһ| þþƷavˮ| ŷСþþþþþ| þþƷƷëƬ| þ| 91Ƶ91þþ| ձWVһһþ㽶| þþþƷ| ޾Ʒþþþȥq | ˾þô߽AV| ѾþþƷ99þ| þۺ97ɫ| þþƷһۺ| պþþþƷӰԺҳ| þ޾Ʒ| ŷպƷþþѹۿ| þ99ƷۺϹҳ| ˳˳ۺþþ| 鶹wwwþùƷ|