/*
* Author: yaoweibin@gmail.com
* Version: $Id: ngx_http_upstream_jvm_route_module.c 31 2009-12-07 06:14:51Z yaoweibin $
*
* Based on the upstream_round_robin and upstream_fair momdule.
*
* This module can be distributed under the same terms as Nginx itself.
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#if (NGX_UPSTREAM_CHECK_MODULE)
#include "ngx_http_upstream_check_handler.h"
#endif
#define SHM_NAME_LEN 256
typedef struct {
ngx_array_t *values;
ngx_array_t *lengths;
ngx_str_t session_cookie;
ngx_str_t session_url;
unsigned reverse:1;
} ngx_http_upstream_jvm_route_srv_conf_t;
typedef struct {
ngx_str_t shm_name;
} ngx_http_upstream_jvm_route_loc_conf_t;
typedef struct ngx_http_upstream_jvm_route_peers_s ngx_http_upstream_jvm_route_peers_t;
typedef struct {
ngx_uint_t nreq; /* active requests to the peer */
ngx_uint_t total_req;
ngx_uint_t last_req_id;
ngx_uint_t fails;
ngx_uint_t total_fails;
time_t accessed;
ngx_int_t current_weight;
} ngx_http_upstream_jvm_route_shared_t;
typedef struct {
ngx_uint_t generation;
ngx_http_upstream_jvm_route_peers_t *peers;
ngx_uint_t total_nreq;
ngx_uint_t total_requests;
ngx_atomic_t lock;
ngx_http_upstream_jvm_route_shared_t stats[1];
} ngx_http_upstream_jvm_route_shm_block_t;
/* ngx_spinlock is defined without a matching unlock primitive */
#define ngx_spinlock_unlock(lock) (void) ngx_atomic_cmp_set(lock, ngx_pid, 0)
typedef struct {
ngx_http_upstream_jvm_route_shared_t *shared;
struct sockaddr *sockaddr;
socklen_t socklen;
ngx_str_t name;
ngx_int_t weight;
ngx_uint_t max_fails;
ngx_uint_t max_busy;
time_t fail_timeout;
ngx_uint_t down; /* unsigned down:1; */
ngx_str_t srun_id;
#if (NGX_UPSTREAM_CHECK_MODULE)
ngx_uint_t check_index;
#endif
#if (NGX_HTTP_SSL)
ngx_ssl_session_t *ssl_session; /* local to a process */
#endif
} ngx_http_upstream_jvm_route_peer_t;
struct ngx_http_upstream_jvm_route_peers_s {
/* data should be shared between processes */
ngx_http_upstream_jvm_route_shm_block_t *shared;
ngx_uint_t current;
ngx_uint_t number;
ngx_str_t *name;
ngx_str_t shm_name;
/* for backup peers support, not really used yet */
ngx_http_upstream_jvm_route_peers_t *next;
ngx_http_upstream_jvm_route_peer_t peer[1];
};
#define NGX_PEER_INVALID (~0UL)
typedef struct {
ngx_http_upstream_jvm_route_srv_conf_t *conf;
ngx_http_upstream_jvm_route_peers_t *peers;
ngx_uint_t current;
uintptr_t *tried;
uintptr_t data;
ngx_str_t cookie;
ngx_uint_t index;
} ngx_http_upstream_jvm_route_peer_data_t;
static void * ngx_http_upstream_jvm_route_create_conf(ngx_conf_t *cf);
static void * ngx_http_upstream_jvm_route_create_loc_conf(ngx_conf_t *cf);
static ngx_int_t ngx_http_upstream_init_jvm_route_peer(ngx_http_request_t *r,
ngx_http_upstream_srv_conf_t *us);
static ngx_int_t ngx_http_upstream_get_jvm_route_peer(ngx_peer_connection_t *pc,
void *data);
static char *ngx_http_upstream_jvm_route(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_http_upstream_jvm_route_set_status(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
static ngx_int_t
ngx_http_upstream_get_jvm_route_peer(ngx_peer_connection_t *pc, void *data);
static void
ngx_http_upstream_free_jvm_route_peer(ngx_peer_connection_t *pc, void *data,
ngx_uint_t state);
#if (NGX_HTTP_SSL)
static ngx_int_t
ngx_http_upstream_jvm_route_set_session(ngx_peer_connection_t *pc, void *data);
static void
ngx_http_upstream_jvm_route_save_session(ngx_peer_connection_t *pc, void *data);
#endif
static ngx_int_t ngx_http_upstream_jvm_route_init_module(ngx_cycle_t *cycle);
static ngx_command_t ngx_http_upstream_jvm_route_commands[] = {
{ ngx_string("jvm_route"),
NGX_HTTP_UPS_CONF|NGX_CONF_TAKE12,
ngx_http_upstream_jvm_route,
0,
0,
NULL },
{ ngx_string("jvm_route_status"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_upstream_jvm_route_set_status,
NGX_HTTP_LOC_CONF_OFFSET,
0,
NULL },
ngx_null_command
};
static ngx_http_module_t ngx_http_upstream_jvm_route_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
NULL, /* init main configuration */
ngx_http_upstream_jvm_route_create_conf, /* create server configuration */
NULL, /* merge server configuration */
ngx_http_upstream_jvm_route_create_loc_conf, /* create location configuration */
NULL /* merge location configuration */
};
ngx_module_t ngx_http_upstream_jvm_route_module = {
NGX_MODULE_V1,
&ngx_http_upstream_jvm_route_module_ctx, /* module context */
ngx_http_upstream_jvm_route_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
ngx_http_upstream_jvm_route_init_module, /* init module */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
static ngx_uint_t ngx_http_upstream_jvm_route_generation = 0;
#define NGX_BITVECTOR_ELT_SIZE (sizeof(uintptr_t) * 8)
static ngx_int_t
ngx_http_upstream_jvm_route_init_module(ngx_cycle_t *cycle)
{
ngx_http_upstream_jvm_route_generation++;
return NGX_OK;
}
static uintptr_t *
ngx_bitvector_alloc(ngx_pool_t *pool, ngx_uint_t size, uintptr_t *small)
{
ngx_uint_t nelts = (size + NGX_BITVECTOR_ELT_SIZE - 1) / NGX_BITVECTOR_ELT_SIZE;
if (small && nelts == 1) {
*small = 0;
return small;
}
return ngx_pcalloc(pool, nelts * NGX_BITVECTOR_ELT_SIZE);
}
static ngx_int_t
ngx_bitvector_test(uintptr_t *bv, ngx_uint_t bit)
{
ngx_uint_t n, m;
n = bit / NGX_BITVECTOR_ELT_SIZE;
m = 1 << (bit % NGX_BITVECTOR_ELT_SIZE);
return bv[n] & m;
}
static void
ngx_bitvector_set(uintptr_t *bv, ngx_uint_t bit)
{
ngx_uint_t n, m;
n = bit / NGX_BITVECTOR_ELT_SIZE;
m = 1 << (bit % NGX_BITVECTOR_ELT_SIZE);
bv[n] |= m;
}
/*
* string1 compares with the string2 in reverse order.
*/
static ngx_int_t
ngx_strncmp_r(u_char *s1, u_char *s2, size_t len1, size_t len2)
{
if (len2 == 0 || len1 == 0) {
return -1;
}
while (s1[--len1] == s2[--len2]) {
if (len2 == 0 || len1 == 0) {
return 0;
}
}
return s1[le
没有合适的资源?快使用搜索试试~ 我知道了~
AJP for Nginx
共54个文件
pm:22个
t:8个
c:6个
需积分: 9 9 下载量 14 浏览量
2014-01-10
13:32:35
上传
评论
收藏 154KB ZIP 举报
温馨提示
Nginx插件,增加对ajp协议的支持,提高效率,已经使用Tomcat 6通过测试。
资源推荐
资源详情
资源评论
收起资源包目录
nginx_ajp_module-master.zip (54个子文件)
nginx_ajp_module-master
ngx_http_ajp_module.h 678B
ngx_http_ajp.h 14KB
ajp.patch 6KB
config_1.1.4- 1KB
config 13B
ngx_http_ajp_handler.h 2KB
ngx_http_upstream_keepalive_module.c 16KB
ngx_http_upstream_jvm_route_module.c 41KB
test
inc
Test
Builder
Module.pm 1KB
More.pm 16KB
Base
Filter.pm 7KB
Base.pm 18KB
Builder.pm 30KB
Spiffy.pm 15KB
Module
Install.pm 12KB
Install
Metadata.pm 18KB
Makefile.pm 12KB
Win32.pm 2KB
TestBase.pm 539B
Fetch.pm 2KB
WriteAll.pm 1KB
AutoInstall.pm 2KB
Include.pm 525B
Base.pm 1KB
Can.pm 2KB
AutoInstall.pm 22KB
test.sh 204B
t
ajp_head.t 929B
ajp_cache.t 2KB
ajp_store.t 1KB
ajp_put.t 1KB
ajp_keepalive.t 2KB
ajp_post.t 17KB
ajp_status.t 1KB
ajp_get.t 938B
README 10KB
lib
Test
Nginx.pm 9KB
Nginx
LWP.pm 13KB
Util.pm 23KB
Socket.pm 53KB
webapps
single_upload_page.jsp 435B
index.html 153B
upload.jsp 453B
README.wiki 21KB
ngx_http_ajp_module.c 30KB
README.markdown 21KB
ngx_http_ajp_msg.c 9KB
README 21KB
ngx_http_ajp_handler.c 27KB
ngx_http_ajp.c 21KB
util
wiki2pod.pl 3KB
pod2markdown.pl 673B
update-readme.sh 148B
config_1.1.4+ 1KB
共 54 条
- 1
资源评论
fany2k3
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功