Lighty的jobs设计
来源:互联网 发布:java 获取磁盘io 编辑:程序博客网 时间:2024/05/22 14:44
本文原创为freas_1990,转载请标明出处:http://blog.csdn.net/freas_1990/article/details/18571411
Lighty把连接分为三类:conns,joblist,fdwaitqueue.
这三类都由connections描述。
其中jobs的添加filter如下:
int joblist_append(server *srv, connection *con) { if (con->in_joblist) return 0; if (srv->joblist->size == 0) { srv->joblist->size = 16; srv->joblist->ptr = malloc(sizeof(*srv->joblist->ptr) * srv->joblist->size); } else if (srv->joblist->used == srv->joblist->size) { srv->joblist->size += 16; srv->joblist->ptr = realloc(srv->joblist->ptr, sizeof(*srv->joblist->ptr) * srv->joblist->size); } srv->joblist->ptr[srv->joblist->used++] = con; return 0;}而fdwaitqueue添加的filter如下:
int fdwaitqueue_append(server *srv, connection *con) { if (srv->fdwaitqueue->size == 0) { srv->fdwaitqueue->size = 16; srv->fdwaitqueue->ptr = malloc(sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); } else if (srv->fdwaitqueue->used == srv->fdwaitqueue->size) { srv->fdwaitqueue->size += 16; srv->fdwaitqueue->ptr = realloc(srv->fdwaitqueue->ptr, sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); } srv->fdwaitqueue->ptr[srv->fdwaitqueue->used++] = con; return 0;}至于connections的设计,如下:
typedef struct { connection **ptr; size_t size; size_t used;} connections;而connection设计如下:
typedef struct { connection_state_t state; /* timestamps */ time_t read_idle_ts; time_t close_timeout_ts; time_t write_request_ts; time_t connection_start; time_t request_start; struct timeval start_tv; size_t request_count; /* number of requests handled in this connection */ size_t loops_per_request; /* to catch endless loops in a single request * * used by mod_rewrite, mod_fastcgi, ... and others * this is self-protection */ int fd; /* the FD for this connection */ int fde_ndx; /* index for the fdevent-handler */ int ndx; /* reverse mapping to server->connection[ndx] */ /* fd states */ int is_readable; int is_writable; int keep_alive; /* only request.c can enable it, all other just disable */ int keep_alive_idle; /* remember max_keep_alive_idle from config */ int file_started; int file_finished; chunkqueue *write_queue; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */ chunkqueue *read_queue; /* a small queue for low-level read ( HTTP request ) [ mem ] */ chunkqueue *request_content_queue; /* takes request-content into tempfile if necessary [ tempfile, mem ]*/ int traffic_limit_reached; off_t bytes_written; /* used by mod_accesslog, mod_rrd */ off_t bytes_written_cur_second; /* used by mod_accesslog, mod_rrd */ off_t bytes_read; /* used by mod_accesslog, mod_rrd */ off_t bytes_header; int http_status; sock_addr dst_addr; buffer *dst_addr_buf; /* request */ buffer *parse_request; unsigned int parsed_response; /* bitfield which contains the important header-fields of the parsed response header */ request request; request_uri uri; physical physical; response response; size_t header_len; buffer *authed_user; array *environment; /* used to pass lighttpd internal stuff to the FastCGI/CGI apps, setenv does that */ /* response */ int got_response; int in_joblist; connection_type mode; void **plugin_ctx; /* plugin connection specific config */ specific_config conf; /* global connection specific config */ cond_cache_t *cond_cache; buffer *server_name; /* error-handler */ buffer *error_handler; int error_handler_saved_status; int in_error_handler; void *srv_socket; /* reference to the server-socket (typecast to server_socket) */#ifdef USE_OPENSSL SSL *ssl;# ifndef OPENSSL_NO_TLSEXT buffer *tlsext_server_name;# endif unsigned int renegotiations; /* count of SSL_CB_HANDSHAKE_START */#endif /* etag handling */ etag_flags_t etag_flags; int conditional_is_valid[COMP_LAST_ELEMENT]; } connection;源代码是最有营养的资源!放下意淫的书籍!enjoy the source code!
0 0
- Lighty的jobs设计
- Lighty的Chunk设计
- Lighty的“自适应”树
- Lighty的“自适应”树
- Lighty的“自适应”树
- 由Jobs的联想
- Steve Jobs的家庭教育
- Jobs的成功
- Steve Jobs的演讲
- Linux的jobs命令
- laravel 的jobs(队列)
- jobs
- lighttpd(lighty) 性能优化
- [收藏]Steve Jobs的人生哲学
- 如何产生archived的jobs
- 如何创建Oracle的jobs
- Schezules&Programs&Jobs的区别
- Schezules&Programs&Jobs的区别
- kmalloc设计
- (写笔记习惯)关于从eclipse导入android studio 中,代码乱码的情况
- Redis的VM实现——终究敌不过业务架构师!
- 64位系统下进程的内存布局
- 将Android下的可执行文件以静态库的形式进行编译
- Lighty的jobs设计
- Windows下给gVim安装插件
- Mac下安装mysql-python失败解决方法
- 启动mysql错误on Mac
- IOS UITableView (三)
- inotify - 监控文件系统
- 修改img的src属性刷新图片时,图片地址相同图片无变化的问题
- PHP Traits代码复用方法浅析
- JQueryAjax+SpringMVC跨域请求