Mercurial > hg > nginx
view src/stream/ngx_stream_upstream.h @ 6133:af7eba90645d
Win32: shared memory base addresses and remapping.
Two mechanisms are implemented to make it possible to store pointers
in shared memory on Windows, in particular on Windows Vista and later
versions with ASLR:
- The ngx_shm_remap() function added to allow remapping of a shared memory
zone to the address originally used for it in the master process. While
important, it doesn't solve the problem by itself as in many cases it's
not possible to use the address because of conflicts with other
allocations.
- We now create mappings at the same address in all processes by starting
mappings at predefined addresses normally unused by newborn processes.
These two mechanisms combined allow to use shared memory on Windows
almost without problems, including reloads.
Based on the patch by Sergey Brester:
http://mailman.nginx.org/pipermail/nginx-devel/2015-April/006836.html
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 27 Apr 2015 18:25:42 +0300 |
parents | 61d7ae76647d |
children | fa663739e115 |
line wrap: on
line source
/* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGX_STREAM_UPSTREAM_H_INCLUDED_ #define _NGX_STREAM_UPSTREAM_H_INCLUDED_ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_stream.h> #include <ngx_event_connect.h> #define NGX_STREAM_UPSTREAM_CREATE 0x0001 #define NGX_STREAM_UPSTREAM_WEIGHT 0x0002 #define NGX_STREAM_UPSTREAM_MAX_FAILS 0x0004 #define NGX_STREAM_UPSTREAM_FAIL_TIMEOUT 0x0008 #define NGX_STREAM_UPSTREAM_DOWN 0x0010 #define NGX_STREAM_UPSTREAM_BACKUP 0x0020 typedef struct { ngx_array_t upstreams; /* ngx_stream_upstream_srv_conf_t */ } ngx_stream_upstream_main_conf_t; typedef struct ngx_stream_upstream_srv_conf_s ngx_stream_upstream_srv_conf_t; typedef ngx_int_t (*ngx_stream_upstream_init_pt)(ngx_conf_t *cf, ngx_stream_upstream_srv_conf_t *us); typedef ngx_int_t (*ngx_stream_upstream_init_peer_pt)(ngx_stream_session_t *s, ngx_stream_upstream_srv_conf_t *us); typedef struct { ngx_stream_upstream_init_pt init_upstream; ngx_stream_upstream_init_peer_pt init; void *data; } ngx_stream_upstream_peer_t; typedef struct { ngx_str_t name; ngx_addr_t *addrs; ngx_uint_t naddrs; ngx_uint_t weight; ngx_uint_t max_fails; time_t fail_timeout; unsigned down:1; unsigned backup:1; } ngx_stream_upstream_server_t; struct ngx_stream_upstream_srv_conf_s { ngx_stream_upstream_peer_t peer; void **srv_conf; ngx_array_t *servers; /* ngx_stream_upstream_server_t */ ngx_uint_t flags; ngx_str_t host; u_char *file_name; ngx_uint_t line; in_port_t port; ngx_uint_t no_port; /* unsigned no_port:1 */ #if (NGX_STREAM_UPSTREAM_ZONE) ngx_shm_zone_t *shm_zone; #endif }; typedef struct { ngx_peer_connection_t peer; ngx_buf_t downstream_buf; ngx_buf_t upstream_buf; off_t received; #if (NGX_STREAM_SSL) ngx_str_t ssl_name; #endif } ngx_stream_upstream_t; ngx_stream_upstream_srv_conf_t *ngx_stream_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags); #define ngx_stream_conf_upstream_srv_conf(uscf, module) \ uscf->srv_conf[module.ctx_index] extern ngx_module_t ngx_stream_upstream_module; #endif /* _NGX_STREAM_UPSTREAM_H_INCLUDED_ */