过五一喽……

April 30th, 2006 | Posted in 叉言叉语   Add Comment
嘿嘿
可以玩喽……
七天啊……
先放两张照片上来,上天双龙峡的照片,我自己拍的还没拷回来,后面那张是我现在的同事们……
大家猜猜那张合影的背景是虾米涅……呵呵……

apache module中取post数据

April 30th, 2006 | Posted in Apache   Add Comment

一共使用三个函数

  1. ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)
    Apache里面说Setup the client to allow Apache to read the request body. 差不多意思就是初始化,第二个参数可以取以下三个值。

    1. REQUEST_NO_BODY
      意为如果request必须没有body,如果有就发一个413错误
    2. REQUEST_CHUNKED_ERROR
      意为request必须不可为chunked,如果有就发一个411错误
    3. REQUEST_CHUNKED_DECHUNK
      意思为如果chunked了,则dechunk。

    对于我们要读取post的数据,只能取后面两个,而chunked则是对长连接的选项了,使用哪个视情况而定。

  2. ap_should_client_block(r)
    检查是否有数据,对于chunked的话会发送一个100 continue的命令让客户端继续发送数据。
  3. ap_get_client_block(r, pBuff, size)
    读取数据

apache及其module的调试

April 30th, 2006 | Posted in Apache   1 Comment
  1. gdb httpd
    用gdb加载httpd进程
  2. (gdb) b break-point
    设置断点,可以设置函数名、行数等……
  3. (gdb) run -X -d /usr/local/apache
    执行httpd,这个是关键的,-X参数会让httpd以debug模式运行,debug模式是单进程的,这样才好调试。-d /usr/local/apache是设置运行的目录。

另外,gdb httpd pid可以attach一个正在运行的httpd来调试。

今天MM生日……

April 26th, 2006 | Posted in 叉言叉语   Add Comment
刚刚下班跑space上来准备写这篇帖子的时候MM发消息过来了,责怪怎么没有上站给她发生日贴……
汗……最近好像默契挺重的……嘿嘿……
MM生日快乐,希望你今天能够快快乐乐的,以后也能一直很快乐……
明天和MM去双龙峡玩,算是补过生日吧,今天不能一起过的遗憾:)
以后要更开心:)

Back to beijing

April 20th, 2006 | Posted in 工作手札   Add Comment
嘿嘿……

下周预告

April 14th, 2006 | Posted in 叉言叉语   Add Comment
下周一周二两天会在南京,不过是考试,嘿嘿……

Thread-safety and POSIX.1

April 13th, 2006 | Posted in GNU/Linux   Add Comment

Thread-safe Versions of POSIX.1 and C-language Functions. From http://www.unix.org/whitepapers/reentrant.html

April 11th, 2006 | Posted in 工作手札   Add Comment
今天早上我那个小弟弟,折腾到八点也不肯吃药,我真的是没法子了……
不过他貌似挺喜欢吃我给他做的早餐的,嘿嘿:)
第二周的第二天,加油加油:)

XML1.0 中文文档(第二版)

April 10th, 2006 | Posted in GNU/Linux   Add Comment

可扩展标记语言(XML)1.0(第二版) To be upgraded to third edition.

新的一周

April 10th, 2006 | Posted in 工作手札   Add Comment
先回顾下周末,周六爷爷要回家去了,上午陪爷爷出去逛了一个上午,下午送完爷爷回到家里的时候已经是晚上九点,在北京就这个不好,来回一跑就是半天:(
然后周日上午洗了好多好多衣服,第一次发现原来洗衣服可以花上半天@.@
下午带着姑姑家的小弟弟出去玩,然后还和MM拌了会嘴的说……
从今天早上开始,这一周早上都要担负起把我那个调皮的弟弟从床上弄到幼儿园的重任,终于体会到小时候父母哄我们是多么的耐心了,因为,把他从床上一直哄到学校真的好痛苦啊T_T
新的一周了,好好工作,只有一直不懈的努力,以后才能过的幸福的说。

第一周

April 7th, 2006 | Posted in 工作手札   Add Comment
真的还不大好写这个第一周的回顾呢,呵呵,只想用光阴似箭四个字来说了,不管啦,回去过周末料……

原来此小小就是彼小小

April 7th, 2006 | Posted in 工作手札   Add Comment
周二的时候头带偶一起讨论一个问题时和我说这就是小小,他的flash做得很牛的。
我当时就挺纳闷的,这个小小和偶刚知道flash时候听说的那个小小,不会是一个人吧,应该没那么巧吧……
昨晚和同事一块回的时候才知道,此小小就是彼小小,中国flash界的泰山北斗,汗……
记得刚开始接触flash的时候,对小小那个是崇拜啊,有如滔滔江水连绵不绝,又如黄河泛滥一发不可收拾……
嘿嘿,能有机会和头、和小小、和现在这些同事,能和传说中的人物在一个办公室里工作,激动的咧……

第四天

April 6th, 2006 | Posted in 工作手札   Add Comment
昨天接了些东西来看,下午的时候整理了下文档,估计今天文档能够整理完的。
整理完了就可以开始接手做了……晚上的时候从易初莲花里面带了一只烤鸡回去:)
五道口这地方还是不熟悉,今天中午还是要出去转转,呵呵……
各位还在梦乡和不在梦乡的早上好……:)

明天

April 5th, 2006 | Posted in 叉言叉语   Add Comment
明天是和MM恋爱100天,今天在短信里问我说明天什么日子,嘿嘿……
寥寥数语,只愿坚持走下去吧,嗯,这是爱。

第三天

April 5th, 2006 | Posted in 工作手札   Add Comment
挖坑先……

About module struct in Apache

April 4th, 2006 | Posted in Apache   Add Comment

在写apache模块的时候,会用到module这个结构体。module这个结构体实际上是module_struct,后面附上了定义。使用的时候通常都是定义一个这个结构体的变量并赋初值,如:

module AP_MODULE_DECLARE_DATA proxy_module =
{
STANDARD20_MODULE_STUFF,
create_proxy_dir_config,    /* create per-directory config structure */
merge_proxy_dir_config,     /* merge per-directory config structures */
create_proxy_config,        /* create per-server config structure */
merge_proxy_config,         /* merge per-server config structures */
proxy_cmds,                 /* command table */
register_hooks
};

其中STANDARD20_MODULE_STUFF这个宏为module_struct中的API version, minor version, module index, name, danamic load handle, next, magic, rewrite_args赋了初值。随后是per-directory configuration structure的初始化、合并函数和per-server configuration structure的初始化、合并函数。command table是command_rec结构的一个数组,依然是宏展开,描述这个模块在配置文件里面的信息。最后的register_hooks指向用于注册hook的函数。

typedef struct module_struct module;
/**
* Module structures.  Just about everything is dispatched through
* these, directly or indirectly (through the command and handler
* tables).
*/
struct module_struct {
/** API version, *not* module version; check that module is
* compatible with this version of the server.
*/
int version;
/** API minor version. Provides API feature milestones. Not checked
*  during module init */
int minor_version;
/** Index to this modules structures in config vectors.  */
int module_index;
/** The name of the module's C file */
const char *name;
/** The handle for the DSO.  Internal use only */
void *dynamic_load_handle;
/** A pointer to the next module in the list
*  @defvar module_struct *next */
struct module_struct *next;
/** Magic Cookie to identify a module structure;  It's mainly
*  important for the DSO facility (see also mod_so).  */
unsigned long magic;
/** Function to allow MPMs to re-write command line arguments.  This
*  hook is only available to MPMs.
*  @param The process that the server is running in.
*/
void (*rewrite_args) (process_rec *process);
/** Function to allow all modules to create per directory configuration
*  structures.
*  @param p The pool to use for all allocations.
*  @param dir The directory currently being processed.
*  @return The per-directory structure created
*/
void *(*create_dir_config) (apr_pool_t *p, char *dir);
/** Function to allow all modules to merge the per directory configuration
*  structures for two directories.
*  @param p The pool to use for all allocations.
*  @param base_conf The directory structure created for the parent directory.
*  @param new_conf The directory structure currently being processed.
*  @return The new per-directory structure created
*/
void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
/** Function to allow all modules to create per server configuration
*  structures.
*  @param p The pool to use for all allocations.
*  @param s The server currently being processed.
*  @return The per-server structure created
*/
void *(*create_server_config) (apr_pool_t *p, server_rec *s);
/** Function to allow all modules to merge the per server configuration
*  structures for two servers.
*  @param p The pool to use for all allocations.
*  @param base_conf The directory structure created for the parent directory.
*  @param new_conf The directory structure currently being processed.
*  @return The new per-directory structure created
*/
void *(*merge_server_config) (apr_pool_t *p, void *base_conf,                                   void *new_conf);
/** A command_rec table that describes all of the directives this module
* defines. */
const command_rec *cmds;
/** A hook to allow modules to hook other points in the request processing.
*  In this function, modules should call the ap_hook_*() functions to
*  register an interest in a specific step in processing the current
*  request.
*  @param p the pool to use for all allocations
*/
void (*register_hooks) (apr_pool_t *p);
};

Apache中的挂钩剖析

April 4th, 2006 | Posted in Apache   Add Comment

From http://fanqiang.chinaunix.net/app/web/2006-02-21/4009.shtml,作者:张中庆。

次日

April 4th, 2006 | Posted in 工作手札   Add Comment
俺文采不好,写起工作日记跟记流水帐似的,嘿嘿……

第一天上班,嘿嘿

April 3rd, 2006 | Posted in 工作手札   Add Comment
早上先是等车,等了半个小时么的公车的说……
然后是打车,等了十几分钟么的taxi的说……
汗,幸亏早上起的早,不然肯定迟的说……
最后打了辆黑车,从颐和园到五道口宰了我15的说……
上午办手续,认同事,挺exciting的说……
下午头给交代了情况和任务,嘿嘿,passion十足的说……

介个就是第一天工作心得,over的说……