﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-大日如来-随笔分类-游戏-编程</title><link>http://www.cppblog.com/kuchao/category/6423.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 19 May 2008 15:23:34 GMT</lastBuildDate><pubDate>Mon, 19 May 2008 15:23:34 GMT</pubDate><ttl>60</ttl><item><title>FreeBSD用SCRT管理的一个问题</title><link>http://www.cppblog.com/kuchao/archive/2008/05/12/49593.html</link><dc:creator>大日如来</dc:creator><author>大日如来</author><pubDate>Sun, 11 May 2008 17:26:00 GMT</pubDate><guid>http://www.cppblog.com/kuchao/archive/2008/05/12/49593.html</guid><wfw:comment>http://www.cppblog.com/kuchao/comments/49593.html</wfw:comment><comments>http://www.cppblog.com/kuchao/archive/2008/05/12/49593.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/kuchao/comments/commentRss/49593.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kuchao/services/trackbacks/49593.html</trackback:ping><description><![CDATA[<p>比如我开了2个终端，ttyp1空着，在ttyp2上gdb loginserver跑起来之后，who看有ttyp1和ttyp2，ttyp1上有bash，sshd，ttyp2上有bash，sshd，gdb，loginserver。</p> <p>我关了ttyp2，再看who只有ttyp1了，ttyp2上的bash和sshd没了，但是gdb和loginserver还在，假如我kill掉loginserver，gdb也会跟着关掉，我现在想要gdb和loginserver重新回到ttyp1的控制里，感觉上就是从ttyp1的STDIN里读，往ttyp2的STDOUT里写，怎么做？</p> <p>gettty貌似有这个功能，但是他不算是一个utility tools，watch可以，带-W参数还可以写，但是需要root权限，而且还是和接管这种感觉差了一点，因为我对服务器管理实在很差，哪位看到了知道怎么做可以留言给我，不甚感激。</p><img src ="http://www.cppblog.com/kuchao/aggbug/49593.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kuchao/" target="_blank">大日如来</a> 2008-05-12 01:26 <a href="http://www.cppblog.com/kuchao/archive/2008/05/12/49593.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>路漫漫其修远兮,吾将上下而求索</title><link>http://www.cppblog.com/kuchao/archive/2008/05/12/49592.html</link><dc:creator>大日如来</dc:creator><author>大日如来</author><pubDate>Sun, 11 May 2008 17:23:00 GMT</pubDate><guid>http://www.cppblog.com/kuchao/archive/2008/05/12/49592.html</guid><wfw:comment>http://www.cppblog.com/kuchao/comments/49592.html</wfw:comment><comments>http://www.cppblog.com/kuchao/archive/2008/05/12/49592.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/kuchao/comments/commentRss/49592.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kuchao/services/trackbacks/49592.html</trackback:ping><description><![CDATA[<p>又是一个月没写BLOG了，这一个月回家基本都不怎么碰电脑，更换平台也一段时间了，FreeBSD留给我的印象最大的是稳定，其次是反应很干脆，比如程序有什么BUG，直接SIGSEGV，比如：</p> <p>int a = 5;</p> <p>printf("%s", a);</p> <p>这个在WIN32平台上只可能是未知结果，FreeBSD就报了错误。</p> <p>还有就是FreeBSD和WIN32的内存管理完全是2个极端，WIN32在物理内存闲置的时候都占用了一半的虚拟内存，而FreeBSD仅仅是在物理内存被吃完，留下512K开始使用虚拟内存。</p> <p>个人感觉，这样的区别是来自一个做桌面，一个做服务，做桌面的总有一些慢轮询需要处理，比如图标的cache啊，各种状态的保存啊，很占内存的东西，但是又不是实时的使用，留在物理内存里纯属浪费，而FreeBSD一开始设计的时候根本没有图形界面，纯纯一个terminal，需要的东西内核都帮你做了，你可以随意开关你认为必要不必要的东西，所以FreeBSD做服务端非常合适的。</p> <p>&nbsp;</p> <p>终于还是把GC加到了服务端里面，mapserver内存从960M涨到了1560，效率上没怎么测试，稳定性感觉略微有点下降，好处可能要在实际应用中才能体会了。</p><img src ="http://www.cppblog.com/kuchao/aggbug/49592.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kuchao/" target="_blank">大日如来</a> 2008-05-12 01:23 <a href="http://www.cppblog.com/kuchao/archive/2008/05/12/49592.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>搬服务端的体会--接着来。</title><link>http://www.cppblog.com/kuchao/archive/2008/04/09/46702.html</link><dc:creator>大日如来</dc:creator><author>大日如来</author><pubDate>Wed, 09 Apr 2008 14:42:00 GMT</pubDate><guid>http://www.cppblog.com/kuchao/archive/2008/04/09/46702.html</guid><wfw:comment>http://www.cppblog.com/kuchao/comments/46702.html</wfw:comment><comments>http://www.cppblog.com/kuchao/archive/2008/04/09/46702.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/kuchao/comments/commentRss/46702.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kuchao/services/trackbacks/46702.html</trackback:ping><description><![CDATA[<a href="http://www.cppblog.com/kuchao/archive/2008/04/09/46566.html">上一篇</a> 说了问题。现在说说重构后的构架。<br>基于freebsd6.3 boost-1.35.0(多处升级，最重要是包含了asio，升级了thread) STLport-5.1.5 消息队列(msgget,msgsnd,msgrcv)<br><br>构架方便借鉴了部分<a  href="http://blog.codingnow.com/">云风</a>的思路。<br>loginserver,gate,gamedb,postoffice,mapserver<br>accountdb去掉了，整合进loginserver里，loginserver直接连oracle，取列表信息后去连gate，gate连gamedb负责发人物列表<br><img  src="http://www.cppblog.com/images/cppblog_com/kuchao/dp.JPG" border="0"><br>家里机器只有画图。。。忍着看吧。。。<br>下面开始都是一个服为一个单位。<br>一个服的gate是可以随时开关的，gate起来的时候会给loginserver和postoffice注册<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">&nbsp;1</span>&nbsp;<span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;GateInfo<br></span><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;name[</span><span style="color: #000000;">25</span><span style="color: #000000;">];<br></span><span style="color: #008080;">&nbsp;4</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;ip[</span><span style="color: #000000;">16</span><span style="color: #000000;">];<br></span><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">short</span><span style="color: #000000;">&nbsp;port;<br></span><span style="color: #008080;">&nbsp;6</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">uint</span><span style="color: #000000;">&nbsp;online;<br></span><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #000000;">};<br></span><span style="color: #008080;">&nbsp;8</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">&nbsp;9</span>&nbsp;<span style="color: #000000;">typedef&nbsp;vector</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">GateInfo</span><span style="color: #000000;">*&gt;</span><span style="color: #000000;">&nbsp;VecGateInfo;<br></span><span style="color: #008080;">10</span>&nbsp;<span style="color: #000000;">VecGateInfo&nbsp;_gateinfo;<br></span><span style="color: #008080;">11</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">12</span>&nbsp;<span style="color: #000000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;当有用户连上或者断开gate时</span><span style="color: #008000;"><br></span><span style="color: #008080;">13</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">sort(_gateinfo.begin(),&nbsp;_gateinfo.end(),&nbsp;GateSort)<br></span><span style="color: #008080;">14</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">15</span>&nbsp;<span style="color: #000000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;这样client取gate信息的时候只需要发给每个gate_group的第一个就行。</span></div>
<br>gamedb是所有userinfo的集结地，有缓存，只在第一次请求的时候把userinfo读进缓存，其余时刻都是写，一个慢线程，5分钟轮询写一遍，某个user更新发给gamedb，由gamedb负责通知其他拷贝同步更新。<br><br>mapserver实际上是一堆服务端的组合总称，这块来自云风的构架，分为chatserver（聊天服务端），mapserver（地图服务端，还可以区分为只带功能性npc地图，或者称为非pk地图，和其他地图），guildserver，dropserver。。。每个server都和postoffice连接，并且按功能和gamedb和其他服务端连接，按功能划分具体的服务端可以很好的把逻辑分散，不会导致某个模块的bug整个服务端的崩溃，在程序员整体调试水平不高的情况下，大大降低出错后分析的难度。<br><br>相比较以前来说就是gamedb后移，数据重心放在gamedb上，只读一次的做法要严格保证gamedb的效率和稳定，否则会死的很抽象。<br><br>一些细节mark下来，boost+asio在freebsd上居然不用kqueue用的是select。。。Orz，这是我在一次单步跟一个内存错误发现的<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">&nbsp;1</span>&nbsp;<span style="color: #008000;">//</span><span style="color: #008000;"><br></span><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;kqueue_reactor_fwd.hpp<br></span><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;~~~~~~~~~~~~~~~~~~~~~~<br></span><span style="color: #008080;">&nbsp;4</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;"><br></span><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;Copyright&nbsp;(c)&nbsp;2003-2008&nbsp;Christopher&nbsp;M.&nbsp;Kohlhoff&nbsp;(chris&nbsp;at&nbsp;kohlhoff&nbsp;dot&nbsp;com)<br></span><span style="color: #008080;">&nbsp;6</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;Copyright&nbsp;(c)&nbsp;2005&nbsp;Stefan&nbsp;Arentz&nbsp;(stefan&nbsp;at&nbsp;soze&nbsp;dot&nbsp;com)<br></span><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;"><br></span><span style="color: #008080;">&nbsp;8</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;Distributed&nbsp;under&nbsp;the&nbsp;Boost&nbsp;Software&nbsp;License,&nbsp;Version&nbsp;1.0.&nbsp;(See&nbsp;accompanying<br></span><span style="color: #008080;">&nbsp;9</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;file&nbsp;LICENSE_1_0.txt&nbsp;or&nbsp;copy&nbsp;at&nbsp;</span><span style="color: #008000; text-decoration: underline;">http://www.boost.org/LICENSE_1_0.txt</span><span style="color: #008000;">)<br></span><span style="color: #008080;">10</span>&nbsp;<span style="color: #008000;"></span><span style="color: #008000;">//<br></span><span style="color: #008080;">11</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;"><br></span><span style="color: #008080;">12</span>&nbsp;<span style="color: #000000;">#ifndef&nbsp;BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP<br></span><span style="color: #008080;">13</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#define</span><span style="color: #000000;">&nbsp;BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP</span><span style="color: #000000;"><br></span><span style="color: #008080;">14</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">15</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#if</span><span style="color: #000000;">&nbsp;defined(_MSC_VER)&nbsp;&amp;&amp;&nbsp;(_MSC_VER&nbsp;&gt;=&nbsp;1200)</span><span style="color: #000000;"><br></span><span style="color: #008080;">16</span>&nbsp;<span style="color: #000000;">#&nbsp;pragma&nbsp;once<br></span><span style="color: #008080;">17</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;defined(_MSC_VER)&nbsp;&amp;&amp;&nbsp;(_MSC_VER&nbsp;&gt;=&nbsp;1200)</span><span style="color: #000000;"><br></span><span style="color: #008080;">18</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">19</span>&nbsp;<span style="color: #000000;">#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">boost</span><span style="color: #000000;">/</span><span style="color: #000000;">asio</span><span style="color: #000000;">/</span><span style="color: #000000;">detail</span><span style="color: #000000;">/</span><span style="color: #000000;">push_options.hpp</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #008080;">20</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">21</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#if</span><span style="color: #000000;">&nbsp;!defined(BOOST_ASIO_DISABLE_KQUEUE)</span><span style="color: #000000;"><br></span><span style="color: #008080;">22</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#if</span><span style="color: #000000;">&nbsp;defined(__MACH__)&nbsp;&amp;&amp;&nbsp;defined(__APPLE__)</span><span style="color: #000000;"><br></span><span style="color: #008080;">23</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">24</span>&nbsp;<span style="color: #000000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;Define&nbsp;this&nbsp;to&nbsp;indicate&nbsp;that&nbsp;epoll&nbsp;is&nbsp;supported&nbsp;on&nbsp;the&nbsp;target&nbsp;platform.</span><span style="color: #008000;"><br></span><span style="color: #008080;">25</span>&nbsp;<span style="color: #008000;"></span><span style="color: #0000ff;">#define</span><span style="color: #000000;">&nbsp;BOOST_ASIO_HAS_KQUEUE&nbsp;1</span><span style="color: #000000;"><br></span><span style="color: #008080;">26</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">27</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;boost&nbsp;{<br></span><span style="color: #008080;">28</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;asio&nbsp;{<br></span><span style="color: #008080;">29</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;detail&nbsp;{<br></span><span style="color: #008080;">30</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">31</span>&nbsp;<span style="color: #000000;">template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">&nbsp;Own_Thread</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #008080;">32</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;kqueue_reactor;<br></span><span style="color: #008080;">33</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">34</span>&nbsp;<span style="color: #000000;">}&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;namespace&nbsp;detail</span><span style="color: #008000;"><br></span><span style="color: #008080;">35</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">}&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;namespace&nbsp;asio</span><span style="color: #008000;"><br></span><span style="color: #008080;">36</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">}&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;namespace&nbsp;boost</span><span style="color: #008000;"><br></span><span style="color: #008080;">37</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;"><br></span><span style="color: #008080;">38</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;defined(__MACH__)&nbsp;&amp;&amp;&nbsp;defined(__APPLE__)</span><span style="color: #000000;"><br></span><span style="color: #008080;">39</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;!defined(BOOST_ASIO_DISABLE_KQUEUE)</span><span style="color: #000000;"><br></span><span style="color: #008080;">40</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">41</span>&nbsp;<span style="color: #000000;">#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">boost</span><span style="color: #000000;">/</span><span style="color: #000000;">asio</span><span style="color: #000000;">/</span><span style="color: #000000;">detail</span><span style="color: #000000;">/</span><span style="color: #000000;">pop_options.hpp</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #008080;">42</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">43</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP</span></div>
反正我只是不负责任的把22和38行屏蔽掉而已。<br><br>消息队列只传递指针，意思就是某个消息由接收方alloc，然后msgsnd这块内存的指针，msgrcv收到这个指针，处理完了free掉，而不是整个消息放进去。<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">1</span>&nbsp;<span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;mymsg&nbsp;{<br></span><span style="color: #008080;">2</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">long</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;mtype;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;message&nbsp;type&nbsp;</span><span style="color: #008000;">*/</span><span style="color: #000000;"><br></span><span style="color: #008080;">3</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mtext[</span><span style="color: #000000;">4</span><span style="color: #000000;">];&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;message&nbsp;text&nbsp;</span><span style="color: #008000;">*/</span><span style="color: #000000;"><br></span><span style="color: #008080;">4</span>&nbsp;<span style="color: #000000;">}<br></span><span style="color: #008080;">5</span>&nbsp;<span style="color: #000000;"></span></div>
说实话当初在msgsnd msgrcv上调试了很久<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">1</span>&nbsp;<span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;packet;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;假设这个packet包括了传进来的包</span><span style="color: #008000;"><br></span><span style="color: #008080;">2</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">mymsg</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;msg&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(mymsg</span><span style="color: #000000;">*</span><span style="color: #000000;">)mem_alloc(</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(mymsg));<br></span><span style="color: #008080;">3</span>&nbsp;<span style="color: #000000;">memcpy(msg</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">mtext,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">packet,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">));<br></span><span style="color: #008080;">4</span>&nbsp;<span style="color: #000000;">msgsnd(msgid,&nbsp;msg,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">),</span><span style="color: #000000;">0</span><span style="color: #000000;">)</span></div>
然后死活提示参数不正确。。。<br><br>逐字逐句读了man msgsnd数十遍之后发现。。。问题在msg-&gt;mtype不能等于0<br><br>ok，公司物理断网，usb口物理破坏。。。囧。。。当然，我要起带头作用，忍。。。<br><img src ="http://www.cppblog.com/kuchao/aggbug/46702.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kuchao/" target="_blank">大日如来</a> 2008-04-09 22:42 <a href="http://www.cppblog.com/kuchao/archive/2008/04/09/46702.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>本次服务端搬平台的一些体会。</title><link>http://www.cppblog.com/kuchao/archive/2008/04/09/46566.html</link><dc:creator>大日如来</dc:creator><author>大日如来</author><pubDate>Tue, 08 Apr 2008 16:01:00 GMT</pubDate><guid>http://www.cppblog.com/kuchao/archive/2008/04/09/46566.html</guid><wfw:comment>http://www.cppblog.com/kuchao/comments/46566.html</wfw:comment><comments>http://www.cppblog.com/kuchao/archive/2008/04/09/46566.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.cppblog.com/kuchao/comments/commentRss/46566.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kuchao/services/trackbacks/46566.html</trackback:ping><description><![CDATA[以前的服务端是win32平台，STLport-5.1.4，boost-1.34.1，asio-0.3.8，apr的内存管理，消息池用的是MSMQ。<br>构架是loginserver，accountdb，gate，gamedb，gameserver，数据流向是：帐号密码-&gt;loginserver-&gt;accountdb-&gt;loginserver-&gt;client-&gt;选区-&gt;gate-&gt;gamedb-&gt;gate-&gt;client-&gt;选人-&gt;gate-&gt;gameserver<br><br>先说说现在的问题，win32平台就不说了^_^，也不谈stlport boost的效率问题，msmq也中规中矩，主要是apr的问题，使用的是这样的形式来做的内存管理
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">&nbsp;1</span>&nbsp;<span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;cUser<br></span><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;apr_pool_t</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;pool;<br></span><span style="color: #008080;">&nbsp;4</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;name[</span><span style="color: #000000;">25</span><span style="color: #000000;">];<br></span><span style="color: #008080;">&nbsp;6</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">ushort</span><span style="color: #000000;">&nbsp;level;<br></span><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.cppblog.com/Images/dot.gif"><br></span><span style="color: #008080;">&nbsp;8</span>&nbsp;<span style="color: #000000;">};<br></span><span style="color: #008080;">&nbsp;9</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">10</span>&nbsp;<span style="color: #000000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;申请</span><span style="color: #008000;"><br></span><span style="color: #008080;">11</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">apr_pool_t</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;pool&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br></span><span style="color: #008080;">12</span>&nbsp;<span style="color: #000000;">apr_pool_create(_mainpool,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">pool);<br></span><span style="color: #008080;">13</span>&nbsp;<span style="color: #000000;">cUser</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;user&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(cUser</span><span style="color: #000000;">*</span><span style="color: #000000;">)apr_pcalloc(pool,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(cUser));<br></span><span style="color: #008080;">14</span>&nbsp;<span style="color: #000000;">user</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">pool&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;pool;<br></span><span style="color: #008080;">15</span>&nbsp;<span style="color: #000000;">strcpy_s(user</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">name,&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">test</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br></span><span style="color: #008080;">16</span>&nbsp;<span style="color: #000000;">user</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">level&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br></span><span style="color: #008080;">17</span>&nbsp;<span style="color: #000000;"><br></span><span style="color: #008080;">18</span>&nbsp;<span style="color: #000000;"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;释放</span><span style="color: #008000;"><br></span><span style="color: #008080;">19</span>&nbsp;<span style="color: #008000;"></span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(user)<br></span><span style="color: #008080;">20</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">21</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(user</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">pool)<br></span><span style="color: #008080;">22</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;apr_pool_destory(user</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">pool);<br></span><span style="color: #008080;">23</span>&nbsp;<span style="color: #000000;">}</span></div>
<br>服务端运行过程中很偶尔会出现user-&gt;pool为空，因为释放是程序结束时统一释放，所以没有理由怀疑释放错误，只能是内存越界，比如<br><br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">1</span><span style="color: #000000;">&nbsp;apr_pool_t</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;pool&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>&nbsp;</span><span style="color: #000000;">2</span><span style="color: #000000;">&nbsp;apr_pool_create(mainpool,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">pool);<br>&nbsp;</span><span style="color: #000000;">3</span><span style="color: #000000;">&nbsp;<br>&nbsp;</span><span style="color: #000000;">4</span><span style="color: #000000;">&nbsp;cUser</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;user&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(cUser</span><span style="color: #000000;">*</span><span style="color: #000000;">)apr_pcalloc(pool,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(cUser)&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">20</span><span style="color: #000000;">);<br>&nbsp;</span><span style="color: #000000;">5</span><span style="color: #000000;">&nbsp;<br>&nbsp;</span><span style="color: #000000;">6</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">20</span><span style="color: #000000;">;&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>&nbsp;</span><span style="color: #000000;">7</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user[i].pool&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;pool;<br>&nbsp;</span><span style="color: #000000;">8</span><span style="color: #000000;">&nbsp;<br>&nbsp;</span><span style="color: #000000;">9</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;这只是个示例，当然不会有人这么做</span><span style="color: #008000;"><br></span><span style="color: #000000;">10</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;假设cUser最后一个变量是&nbsp;char&nbsp;temp[100];</span><span style="color: #008000;"><br></span><span style="color: #000000;">11</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;cUser<br></span><span style="color: #000000;">12</span><span style="color: #000000;">&nbsp;{<br></span><span style="color: #000000;">13</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;apr_pool_t</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;pool;<br></span><span style="color: #000000;">14</span><span style="color: #000000;">&nbsp;<br></span><span style="color: #000000;">15</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;name[</span><span style="color: #000000;">25</span><span style="color: #000000;">];<br></span><span style="color: #000000;">16</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">ushort</span><span style="color: #000000;">&nbsp;level;<br></span><span style="color: #000000;">17</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;temp[</span><span style="color: #000000;">100</span><span style="color: #000000;">];<br></span><span style="color: #000000;">18</span><span style="color: #000000;">&nbsp;};<br></span><span style="color: #000000;">19</span><span style="color: #000000;">&nbsp;memcpy(user[</span><span style="color: #000000;">0</span><span style="color: #000000;">].temp,&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">test</span><span style="color: #000000;">"</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">104</span><span style="color: #000000;">);<br></span><span style="color: #000000;">20</span><span style="color: #000000;">&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;这个时候user[1]的pool就是空的了。</span></div>
<br>因为构架是我做的，具体逻辑不是我写的，在几十万行代码里一点一点跟哪里出错实在太渺茫，而且有点怀疑apr内部是否有bug，因为看错误的内存，明显整个user都是被apr_pool_destroy掉的。so。。这次不用apr了，那么大个库使用一个apr_pool是有点杀鸡牛刀的感觉。<br><br>这次简简单单定义<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;mem_alloc(size_t&nbsp;size);<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;mem_realloc(</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p,&nbsp;size_t&nbsp;size);<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;mem_free(</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p);<br><br></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;实现</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;mem_alloc(size_t&nbsp;size)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;malloc(size);<br><br></span><span style="color: #000000;">#ifdef&nbsp;_DEBUG<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(p)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(p,&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">,&nbsp;size);<br></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;p;<br>}<br><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;mem_realloc(</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p,&nbsp;size_t&nbsp;size)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;realloc(p,&nbsp;size);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;p;<br>}<br><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;mem_free(</span><span style="color: #0000ff;">void</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;p)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(p)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free(p);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}</span></div>
<br><br>当然后面打算带上gc，暂时直接申请内存方便valgrind挑错。<br><br><br>构架的问题就大了，一开始的设计是单loginserver多gate，单gate对单gameserver，后来发现一个gameserver带30几张地图，跑5000+npc简直就是自残，于是改，改单gate带多gameserver，问题来了，我们的构架是gamedb只和gate联系，一旦跨地图组队，user信息就要从一个gameserver带到gate再发给另一个gameserver，以前只考虑了由gate保存user信息，gameserver只是一份copy，更新数据方便，但是现在gate的负担超级重。<br><br>还有数据库问题，用的oracle，oci直接操作，accountdb没问题，gamedb是来了请求就去数据库拿或者写，没有做user的缓存，而且是整个user结构体带来带去，通信量特别大。结果是经常报告statement操作的游标过多，提高oracle的64个游标数量只是暂时解决方案。经常选了服就卡住，拿不到人物信息。<br><br>最主要就是msmq轮询取消息process的时候没有用阻塞模式（或者没有阻塞模式？）<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">1</span>&nbsp;<span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(</span><span style="color: #000000;">0</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;MSMQGetMessage(<img src="http://www.cppblog.com/Images/dot.gif">))<br></span><span style="color: #008080;">2</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">3</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;Sleep(</span><span style="color: #000000;">1</span><span style="color: #000000;">);<br></span><span style="color: #008080;">4</span>&nbsp;<span style="color: #000000;">}<br></span><span style="color: #008080;">5</span>&nbsp;<span style="color: #000000;"></span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br></span><span style="color: #008080;">6</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">7</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;Process_Packet(<img src="http://www.cppblog.com/Images/dot.gif">);<br></span><span style="color: #008080;">8</span>&nbsp;<span style="color: #000000;">}</span></div>
<br>问题出在这个sleep(1)上了，不sleep，4个msmq线程，npc的process被抢的什么都干不成，sleep的话cpu就死活利用不上去。懒得找msmq的阻塞模式了。<br><br>还有就是设计上的问题了，比如<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080;">1</span>&nbsp;<span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;User_Save_Info<br></span><span style="color: #008080;">2</span>&nbsp;<span style="color: #000000;">{<br></span><span style="color: #008080;">3</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;name[</span><span style="color: #000000;">25</span><span style="color: #000000;">];</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;没问题，12个中文字的名字。</span><span style="color: #008000;"><br></span><span style="color: #008080;">4</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;gender;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;性别，大哥，你有42亿种性别么？</span><span style="color: #008000;"><br></span><span style="color: #008080;">5</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;facestyle;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;脸型，同上</span><span style="color: #008000;"><br></span><span style="color: #008080;">6</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;hairstyle;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;发型，同上</span><span style="color: #008000;"><br></span><span style="color: #008080;">7</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.cppblog.com/Images/dot.gif"></span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;后面类似的不说了。</span><span style="color: #008000;"><br></span><span style="color: #008080;">8</span>&nbsp;<span style="color: #008000;"></span><span style="color: #000000;">};</span></div>
<br>我就说策划大哥们，我为了省包头的2字节绞尽脑汁，你们可好。。。无语了。。。<br><br>Item_Info_Save是存装备的，我们的装备有随机属性，但是他们居然把装备的通用属性都由服务器来发，最郁闷的是设计npc死亡掉落物品数量达到50件。。。就是一个npc死亡，我需要发8(小队人数)*50(装备个数)*sizeof(Item_Info_Save)(这个sizeof至少100字节)。。。<br><br>ok问题暂时说到这里，下一贴说重构后的改动。<br><img src ="http://www.cppblog.com/kuchao/aggbug/46566.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kuchao/" target="_blank">大日如来</a> 2008-04-09 00:01 <a href="http://www.cppblog.com/kuchao/archive/2008/04/09/46566.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>昨天晚上花了7个小时调试一个bug，很痛苦的经历。</title><link>http://www.cppblog.com/kuchao/archive/2008/03/18/44781.html</link><dc:creator>大日如来</dc:creator><author>大日如来</author><pubDate>Tue, 18 Mar 2008 09:22:00 GMT</pubDate><guid>http://www.cppblog.com/kuchao/archive/2008/03/18/44781.html</guid><wfw:comment>http://www.cppblog.com/kuchao/comments/44781.html</wfw:comment><comments>http://www.cppblog.com/kuchao/archive/2008/03/18/44781.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/kuchao/comments/commentRss/44781.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kuchao/services/trackbacks/44781.html</trackback:ping><description><![CDATA[一开始是这样，某个程序在debug模式下写的一段附魔效果的代码，测试正常后提交。<br>我这里release编译，F5测试了没问题。提交测试人员后被告知没有附魔效果。我继续F5测试没任何问题，和测试人员争执后发现。。。<br>如果用挂着调试器没有任何问题，直接双击exe就是没有效果。<br><br>最后发现是一个变量没有在类构造的时候初始化。<br>是一个bool类型的变量，问题是，为什么挂这调试器这个变量就是true，直接双击exe这个变量就是false？？？ 
<img src ="http://www.cppblog.com/kuchao/aggbug/44781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kuchao/" target="_blank">大日如来</a> 2008-03-18 17:22 <a href="http://www.cppblog.com/kuchao/archive/2008/03/18/44781.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>