另外一篇 : race condition
參考: Mantis : http://www.mantisbt.org/guidelines.php
中文翻譯: http://www.ichiayi.com/wikipage/tech/mantis_coding
First, start off by reading the PHP Coding Standards document. I’ve deviated in a few places but just about everything in the document applies here as well.
Above all, write code that is easy to read and maintain. Comment blocks of code and functions at all times. And get on my case if I deviate too much as well!
$query = "SELECT * FROM $g_mantis_bug_table WHERE id='1'";
for (...) { blah } or if (...) { blah }
if (...) { blah1 } else { blah2 }
tbl_term
term_id | term |
1 | ipod |
2 | apple |
3 | nano |
4 | iphone |
tbl_doc
doc_id | text_content | uptime |
1 | 【蘋果先生】Moshi iGlaze Apple iPhone 3G 專用保護殼 黑/紅/白 | … |
2 | iTunes Gift Card蘋果線上音樂商店預付卡儲值Apple iTunes Shop Ipod Nano Shuffle iphone Mp3電影歌曲下載促銷 | … |
3 | Apple iPhone 3G (8G) |
tbl_lookup
id | term_id | doc_id |
1 | 2 | 1 |
2 | 4 | 1 |
3 | 2 | 2 |
4 | 1 | 2 |
5 | 3 | 2 |
6 | 4 | 2 |
7 | 2 | 3 |
8 | 4 | 3 |
♥ ♥ ♥ 如果這頁訊息對您有幫助 請幫我點上方廣告↑ ↑ ↑ 感謝您的幫助 ♥ ♥ ♥
FILE* fp = fopen(path, "r"); if (fp) { // file exists fclose(fp); } else { // file doesn't exist }
執行程式時, 若遇到
./update_item: error while loading shared libraries: libsqlrclientwrapper-0.40.so.1: cannot open shared object file: No such file or directory
像這樣的錯誤訊息 , 表示程式中所需的 so 檔(share library) 沒找到 , 要修改 /etc/ld.so.conf 加上這個目錄 , 改完要下 ldconfig –v 讓路徑生效
可以用 ldd 看該程式所使用到的 shared library 有那些, 及 lib 路徑
—–
以下是 gentoo 的標準解法 , 其他版本的 linux 則不太相同!!
cat /etc/ld.so.conf 這個檔是由 env-update 產生的 , 所以再繼續看一下 /etc/env.d 下 , 究竟有啥
# ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /usr/local/lib /usr/i686-pc-linux-gnu/lib /usr/lib/gcc/i686-pc-linux-gnu/4.1.2 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1 /usr/local/firstworks/lib
參考資料, 這是 compile sqlrelay 列出來的 information
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
/bin/sh ../../libtool –mode=finish /usr/local/firstworks/lib
PATH=”$PATH:/sbin” ldconfig -n /usr/local/firstworks/lib
———————————————————————-
Libraries have been installed in:
/usr/local/firstworks/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’
在 /etc/env.d 下建立一個 90sqlrelay
內容是
LDPATH="/usr/local/firstworks/lib"
再run : env-update , 就看到 /etc/ld.so.conf 多了正確的 lib path 了
// ———————–
[12/6/13 下午4:37:54] RUTEN AA: 到 /usr/lib 找出原生的 .so 檔,應該會是 libsqlrclientwrapper-0.40.so.xxx.xxx
[12/6/13 下午4:38:13] RUTEN AA: ln -s libsqlrclientwrapper-0.40.so.xxx.xxx 到 loss 的 libsqlrclientwrapper-0.40.so.1.0.0
[12/6/13 下午4:38:17] RUTEN AA: 再 ldconfig
[12/6/13 下午4:40:53] RUTEN AA: 可以用 ldconfig -p 看是不是已經把 libsqlrclientwrapper-0.40.so.1 給 load 進來了