随笔分类 -  GNU

GNU SOFTWARE
摘要:/*ping program for learning IP protocol author: jeff date: 2014/10/25*/#include #include #include #include #include static int ICMP_create();... 阅读全文
posted @ 2014-10-25 16:08 holycrap 阅读(236) 评论(0) 推荐(0)
摘要:面向模式的软件体系结构,卷2,详细介绍并发网络服务器C 语言常见问题集 阅读全文
posted @ 2014-07-05 10:41 holycrap 阅读(355) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #include #include #include #include #include #include "common.h"#include "serversignal.... 阅读全文
posted @ 2014-07-04 15:46 holycrap 阅读(177) 评论(0) 推荐(0)
摘要:1. 实现基础的信号处理 sigaction使用前一定内存清零2. 实现基础的进程模型 wait 等待子进程结束#include #include #include #include #include "common.h"#include "serversignal.h"static volat... 阅读全文
posted @ 2014-07-03 07:25 holycrap 阅读(256) 评论(0) 推荐(0)
摘要:/**** test how many threads can be created in x86 32 system* * ubuntu 13.0***************************************************************... 阅读全文
posted @ 2014-07-01 21:12 holycrap 阅读(355) 评论(0) 推荐(0)
摘要:#include #include int gcond=0;pthread_mutex_t pm;pthread_cond_t pcond;static void *thread_func(void *arg){ do{ pthread_mute... 阅读全文
posted @ 2014-06-30 17:18 holycrap 阅读(182) 评论(0) 推荐(0)
摘要:Checklist:每项任务是否有明确的评价标准?每项任务是否有否有明确的时间安排?挑战性的工作是否安排在上午了?决定您一天绩效的关键事情是什么?是否考虑了必要的风险预留时间?是否留出了总结和第二天计划的30min?是否考虑了做下周计划的时间?时间粒度是否在2h以下?谁会打搅您?怎么办?第二天一来第... 阅读全文
posted @ 2014-06-26 16:14 holycrap 阅读(180) 评论(0) 推荐(0)
摘要:#include "common.h"#include "pool.h"#include static inline void *objmem_to_obj(void *objmem){return objmem + sizeof(pool_obj_head_t);}static inline vo... 阅读全文
posted @ 2014-06-25 09:35 holycrap 阅读(190) 评论(0) 推荐(0)
摘要:#ifndef LISTHHHHHHH#define LISTHHHHHHH#include "common.h"/* stolen from kernel */typedef struct list_node { struct list_node *next; struct list_... 阅读全文
posted @ 2014-06-17 15:06 holycrap 阅读(216) 评论(0) 推荐(0)
摘要:#ifndef COMMON__H#define COMMON__H#include #include #include #include #include #define POWEROF2(x) ((((x)-1) & (x)) == 0)#define CACHE_LINE_SIZE 64#de... 阅读全文
posted @ 2014-06-17 15:05 holycrap 阅读(551) 评论(0) 推荐(0)
摘要:1. scoket函数中PF_INET AF_INET区别在UNIX系列中,PF_INET表示poxis, BSD系列用AF_INET2. in_addr_t inet_addr(const char *cp);入参是字符型ip,in_addr_t 为uint32_t3. if (setsockop... 阅读全文
posted @ 2014-05-19 15:36 holycrap 阅读(186) 评论(0) 推荐(0)
摘要:#ifndef POOL_HHH#define POOL_HHH#include "common.h"/* simple and fast obj pool without multi-thread support */typedef uint32_t pool_size_t;typedef uin... 阅读全文
posted @ 2014-05-04 15:07 holycrap 阅读(3587) 评论(0) 推荐(0)
摘要:最简模型while(1) { accept(); recv(); do(); send(); }这是服务端程序的最简模型:来一个连接,读取数据(请求),干活(处理),返回数据(应答)。同一时间只为一个客户端服务。事件驱动要考虑支持多个客户端,就有了选择,有了选择就叫设计。我们有两个选择:1. 采用select或poll(epoll)多路复用技术,同时监听多个连接以及listen socket的事件。这个叫事件驱动。2. 采用多线程(进程)技术,主线程accept一个连接,就创建或者从线程池中分配一个线程,一个线程处理一个连接。这个叫线程驱动。两者其实没有本质区别,都是中断驱动。第一个增加了编程 阅读全文
posted @ 2014-04-09 17:01 holycrap 阅读(701) 评论(0) 推荐(0)
摘要:du | awk '{if($1 > 200000) print $2}' 阅读全文
posted @ 2014-03-18 14:09 holycrap 阅读(117) 评论(0) 推荐(0)
摘要:1. 不要使用extern来做函数和变量的定义extern int g_test=10;这样做编译器会认为是变量定义而非声明;2. 尽量避免使用extern来处理全局变量和函数声明使用了extern说明,使用了其他模块的全局变量,或者在头文件中没有声明的函数。正确的解决办法应该是模块间接口应该定义清楚,而不是用extern来进行跨模块处理 阅读全文
posted @ 2014-02-22 16:55 holycrap 阅读(183) 评论(0) 推荐(0)
摘要:#ifndef __SIGNAL_COMMON_H#define __SIGNAL_COMMON_H#include #define NGX_OK 0#define NGX_ERROR -1#define NGX_AGAIN -2#define NGX_BUSY -3#define NGX_DONE -4#define NGX_DECLINED -5#define NGX_ABORT -6#define ngx_memset_zero(bu... 阅读全文
posted @ 2014-01-21 12:22 holycrap 阅读(218) 评论(0) 推荐(0)
摘要:#include #include #include #include "mime.h"#include "http_common.h"static const char* methods[]={ "GET", "POST"};static int get_version(const char* versionPos, char* version){ char* versionEnd = NULL; int versionlen = 0; if(versionPos == NULL || version == NU 阅读全文
posted @ 2014-01-14 15:01 holycrap 阅读(185) 评论(0) 推荐(0)
摘要:#include #include #include #include #include /*-----------------------------------------------------------------functionname: file_existparam: NAreturn: NAauthor: xxxx check if file is exist in webapp history: create by xxxx, 2014.1.08, add simple abilities-------------------------... 阅读全文
posted @ 2014-01-14 14:39 holycrap 阅读(153) 评论(0) 推荐(0)
摘要:#include #include "mime.h"static STR_MIME_MAP mime_map[]= { MIME_MAP(MIME_STR_GEN) };void get_mime_type(const char* filename, EN_MIME_TYPE* filetype){ int i =0; for(i=0; i MIME_ELSE || filetype < 0) return NULL; return mime_map[filetype].mimetype;}#ifndef __MIME__H#defi... 阅读全文
posted @ 2014-01-14 14:38 holycrap 阅读(254) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include "mime.h"#include "http_common.h"#include "http_webapp.h"static STR_STATUS_MAP resp_map[]={HTTP_STATUS_MAP(HTTP_MAP_GEN)};/*------------------------------------------------------------------------------------ 阅读全文
posted @ 2014-01-14 14:37 holycrap 阅读(195) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示