1 Star 0 Fork 28

microinfo / bolt

forked from liexusong / bolt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bolt.h 2.68 KB
一键复制 编辑 原始数据 按行查看 历史
liexusong 提交于 2015-08-30 13:43 . add water mark feature
#ifndef __BOLT_H
#define __BOLT_H
#include <pthread.h>
#include <event.h>
#include "http_parser.h"
#include "hash.h"
#include "list.h"
#include "log.h"
#define BOLT_MIN_CACHE_SIZE (1024 * 1024 * 10) /* 10MB */
#define BOLT_FILENAME_LENGTH 1024
#define BOLT_RBUF_SIZE 2048
#define BOLT_WBUF_SIZE 512
#define BOLT_LF '\n'
#define BOLT_CR '\r'
#define BOLT_CRLF "\r\n"
#define BOLT_HTTP_STATE_START 0
#define BOLT_HTTP_STATE_CR 1
#define BOLT_HTTP_STATE_CRLF 2
#define BOLT_HTTP_STATE_CRLFCR 3
#define BOLT_HTTP_STATE_CRLFCRLF 4
#define BOLT_SEND_HEADER_STATE 1
#define BOLT_SEND_CONTENT_STATE 2
#define BOLT_WATERMARK_PADDING 10
#define BOLT_VERSION "V0.2"
typedef struct {
char *host;
short port;
int workers;
char *logfile;
int logmark;
int daemon;
int max_cache; /* The max cache size */
int gc_threshold; /* The range 1 ~ 100 */
char *path;
int path_len;
char *watermark;
int watermark_enable;
} bolt_setting_t;
typedef struct {
int sock;
struct event_base *ebase;
struct event event;
/* Image cache info */
pthread_mutex_t cache_lock;
jk_hash_t *cache_htb;
struct list_head gc_lru;
jk_hash_t *waiting_htb;
/* Task queue info */
pthread_mutex_t task_lock;
pthread_cond_t task_cond;
struct list_head task_queue;
/* Wakeup queue info */
pthread_mutex_t wakeup_lock;
struct list_head wakeup_queue;
int wakeup_notify[2];
struct event wakeup_event;
int connections;
int total_mem_used;
} bolt_service_t;
typedef struct {
struct list_head link; /* Link LRU */
int size;
int refcount;
void *cache;
char filename[BOLT_FILENAME_LENGTH];
int fnlen;
} bolt_cache_t;
typedef struct {
struct list_head link; /* Link waiting queue/free queue */
int sock;
int http_code;
int recv_state;
int send_state;
int keepalive;
int parse_error;
struct event revent;
struct event wevent;
int revset:1;
int wevset:1;
struct http_parser hp;
/* read buffer */
char rbuf[BOLT_RBUF_SIZE];
char *rpos;
char *rend;
char *rlast;
/* write buffer */
char wbuf[BOLT_WBUF_SIZE];
char *wpos;
char *wend;
bolt_cache_t *icache;
int fnlen;
char filename[BOLT_FILENAME_LENGTH];
} bolt_connection_t;
typedef struct {
struct list_head link; /* Link all tasks */
int fnlen;
char filename[BOLT_FILENAME_LENGTH];
} bolt_task_t;
typedef struct {
struct list_head link; /* Link all wait queue */
struct list_head wait_conns;
} bolt_wait_queue_t;
extern bolt_setting_t *setting;
extern bolt_service_t *service;
#endif
1
https://gitee.com/microinfo/bolt.git
git@gitee.com:microinfo/bolt.git
microinfo
bolt
bolt
master

搜索帮助