Skip to content

Commit

Permalink
Introduced the NGX_COMPAT macro.
Browse files Browse the repository at this point in the history
When enabled, some structures are padded to be size compatible
with their NGINX Plus versions.
  • Loading branch information
mdocguard committed Sep 29, 2016
1 parent 833d03a commit c40de74
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/core/ngx_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,17 @@ typedef intptr_t ngx_flag_t;
#define NGX_MAX_INT32_VALUE (uint32_t) 0x7fffffff


#if (NGX_COMPAT)

#define NGX_COMPAT_BEGIN(slots) uint64_t spare[slots];
#define NGX_COMPAT_END

#else

#define NGX_COMPAT_BEGIN(slots)
#define NGX_COMPAT_END

#endif


#endif /* _NGX_CONFIG_H_INCLUDED_ */
8 changes: 7 additions & 1 deletion src/core/ngx_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@
#define NGX_MODULE_SIGNATURE_33 "0"
#endif

#if (NGX_COMPAT)
#define NGX_MODULE_SIGNATURE_34 "1"
#else
#define NGX_MODULE_SIGNATURE_34 "0"
#endif

#define NGX_MODULE_SIGNATURE \
NGX_MODULE_SIGNATURE_0 NGX_MODULE_SIGNATURE_1 NGX_MODULE_SIGNATURE_2 \
NGX_MODULE_SIGNATURE_3 NGX_MODULE_SIGNATURE_4 NGX_MODULE_SIGNATURE_5 \
Expand All @@ -224,7 +230,7 @@
NGX_MODULE_SIGNATURE_24 NGX_MODULE_SIGNATURE_25 NGX_MODULE_SIGNATURE_26 \
NGX_MODULE_SIGNATURE_27 NGX_MODULE_SIGNATURE_28 NGX_MODULE_SIGNATURE_29 \
NGX_MODULE_SIGNATURE_30 NGX_MODULE_SIGNATURE_31 NGX_MODULE_SIGNATURE_32 \
NGX_MODULE_SIGNATURE_33
NGX_MODULE_SIGNATURE_33 NGX_MODULE_SIGNATURE_34


#define NGX_MODULE_V1 \
Expand Down
3 changes: 3 additions & 0 deletions src/event/ngx_event_connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ struct ngx_peer_connection_s {

/* ngx_connection_log_error_e */
unsigned log_error:2;

NGX_COMPAT_BEGIN(2)
NGX_COMPAT_END
};


Expand Down
9 changes: 9 additions & 0 deletions src/http/ngx_http_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ typedef struct {

unsigned down:1;
unsigned backup:1;

NGX_COMPAT_BEGIN(6)
NGX_COMPAT_END
} ngx_http_upstream_server_t;


Expand Down Expand Up @@ -229,6 +232,9 @@ typedef struct {
#endif

ngx_str_t module;

NGX_COMPAT_BEGIN(2)
NGX_COMPAT_END
} ngx_http_upstream_conf_t;


Expand Down Expand Up @@ -382,6 +388,9 @@ struct ngx_http_upstream_s {
unsigned request_sent:1;
unsigned request_body_sent:1;
unsigned header_sent:1;

NGX_COMPAT_BEGIN(1)
NGX_COMPAT_END
};


Expand Down
3 changes: 3 additions & 0 deletions src/http/ngx_http_upstream_round_robin.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct ngx_http_upstream_rr_peer_s {
#endif

ngx_http_upstream_rr_peer_t *next;

NGX_COMPAT_BEGIN(32)
NGX_COMPAT_END
};


Expand Down
3 changes: 3 additions & 0 deletions src/stream/ngx_stream_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typedef struct {

unsigned down:1;
unsigned backup:1;

NGX_COMPAT_BEGIN(4)
NGX_COMPAT_END
} ngx_stream_upstream_server_t;


Expand Down
3 changes: 3 additions & 0 deletions src/stream/ngx_stream_upstream_round_robin.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct ngx_stream_upstream_rr_peer_s {
#endif

ngx_stream_upstream_rr_peer_t *next;

NGX_COMPAT_BEGIN(25)
NGX_COMPAT_END
};


Expand Down

0 comments on commit c40de74

Please sign in to comment.