1、修改文件src/stream/ngx_stream.c
#define SESSION_FLUSH_TIME 1000
static ngx_event_t ev_cleanup;
static ngx_connection_t dummy;
int client_send(char* server_type, char * message);
static void ngx_heartbeat_timer ( ngx_event_t *ev)
{
ngx_log_error(NGX_LOG_INFO,ev->log,0," ngx_accesskey_timer ");
ngx_log_debug(NGX_LOG_DEBUG_EVENT, ev->log, 0,"ngx_accesskey_timer");
/*-----------------------增加自己的代码实现------------------------*/
ngx_add_timer(&ev_cleanup,SESSION_FLUSH_TIME);
}
static ngx_int_t ngx_stream_init_process(ngx_cycle_t *cf)
{
ngx_memzero(&ev_cleanup,sizeof(ngx_event_t));
ev_cleanup.handler = ngx_heartbeat_timer ;
ev_cleanup.log = cf->log;
dummy.fd=(ngx_socket_t)-1;
ev_cleanup.data=&dummy;
ngx_add_timer(&ev_cleanup,SESSION_FLUSH_TIME);
return NGX_OK;
}
ngx_module_t ngx_stream_module = {
NGX_MODULE_V1,
&ngx_stream_module_ctx, /* module context */
ngx_stream_commands, /* module directives */
NGX_CORE_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
ngx_stream_init_process, /* init process */
//NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
2、