@@ -26,7 +26,6 @@ static char *ngx_http_add_params(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
26
26
static char * ngx_http_fs_sdk (ngx_conf_t * cf , void * post , void * data );
27
27
static ngx_conf_post_handler_pt ngx_http_fs_sdk_p = ngx_http_fs_sdk ;
28
28
29
- #if FLAGSHIP_SDK_ENABLED
30
29
typedef struct
31
30
{
32
31
ngx_array_t * params ;
@@ -35,7 +34,6 @@ typedef struct
35
34
ngx_str_t visitor_flags ;
36
35
37
36
} ngx_http_fs_sdk_init_loc_conf_t ;
38
- #endif
39
37
40
38
static void * ngx_http_fs_sdk_init_create_loc_conf (ngx_conf_t * cf )
41
39
{
@@ -49,8 +47,8 @@ static void *ngx_http_fs_sdk_init_create_loc_conf(ngx_conf_t *cf)
49
47
50
48
return conf ;
51
49
}
52
- #if FLAGSHIP_SDK_ENABLED
53
50
51
+ #if FLAGSHIP_SDK_ENABLED
54
52
static int flagship_sdk_initialized = 0 ;
55
53
56
54
static ngx_str_t env_id_string ;
@@ -61,7 +59,6 @@ static ngx_str_t log_level_string;
61
59
static void (* init_flagship )(char * , char * , int , char * );
62
60
static char * (* get_all_flags )(char * , char * );
63
61
#endif
64
-
65
62
/**
66
63
* This module provided directive: fs_init, set_visitor_id, set_visitor_context, get_all_flags.
67
64
*
@@ -103,10 +100,6 @@ static ngx_command_t ngx_http_fs_sdk_commands[] = {
103
100
ngx_null_command /* command termination */
104
101
};
105
102
106
- /* The sdk init string. */
107
- //static u_char ngx_sdk_init[] = SDK_INIT;
108
- //static u_char ngx_it_works[] = IT_WORKS;
109
-
110
103
/* The module context. */
111
104
static ngx_http_module_t ngx_http_fs_sdk_module_ctx = {
112
105
ngx_http_fs_sdk_add_variables , /* preconfiguration */
@@ -214,6 +207,7 @@ static void initialize_flagship_sdk(char *sdk_path, ngx_http_request_t *r)
214
207
215
208
//create the sdk init handle
216
209
init_flagship ((char * )env_id_string .data , (char * )api_key_string .data , 60 , (char * )log_level_string .data );
210
+
217
211
flagship_sdk_initialized = 1 ;
218
212
}
219
213
#endif
@@ -259,14 +253,6 @@ static ngx_int_t ngx_http_fs_sdk_get_all_flags_handler(ngx_http_request_t *r)
259
253
out .buf = b ;
260
254
out .next = NULL ; /* just one buffer */
261
255
262
- /* #if FLAGSHIP_SDK_ENABLED
263
-
264
-
265
-
266
- #else
267
-
268
- #endif */
269
-
270
256
b -> last = ngx_sprintf (b -> last , "Active connections: %s \n" , cglcf -> visitor_flags .data );
271
257
272
258
r -> headers_out .status = NGX_HTTP_OK ;
@@ -277,12 +263,6 @@ static ngx_int_t ngx_http_fs_sdk_get_all_flags_handler(ngx_http_request_t *r)
277
263
278
264
b -> last_in_chain = 1 ;
279
265
280
- /* b->pos = (u_char *)msg; */ /* first position in memory of the data */
281
- /* b->last = (u_char *)msg + ((long int)ngx_strlen((const char *)msg)); */ /* last position in memory of the data */
282
-
283
- /* b->memory = 1; */ /* content is in read-only memory */
284
- /* b->last_buf = 1; */ /* there will be no more buffers in the request */
285
-
286
266
/* Sending the headers for the reply. */
287
267
r -> headers_out .status = NGX_HTTP_OK ; /* 200 status code */
288
268
/* Get the content length of the body. */
@@ -318,6 +298,7 @@ static char *ngx_http_add_params(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
318
298
pcf = ngx_http_conf_get_module_srv_conf (cf , ngx_http_core_module );
319
299
pcf -> handler = ngx_http_fs_sdk_get_all_flags_handler ;
320
300
301
+ #if FLAGSHIP_SDK_ENABLED
321
302
ngx_str_t * value ;
322
303
ngx_array_t * * params ;
323
304
@@ -355,6 +336,7 @@ static char *ngx_http_add_params(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
355
336
356
337
log_level_string .data = value [4 ].data ;
357
338
log_level_string .len = ngx_strlen (log_level_string .data );
339
+ #endif
358
340
359
341
return NGX_CONF_OK ;
360
342
}
@@ -363,7 +345,7 @@ static char *ngx_http_get_all_flags(ngx_conf_t *cf, ngx_command_t *cmd, void *co
363
345
{
364
346
ngx_http_core_loc_conf_t * clcf ; /* pointer to core location configuration */
365
347
366
- /* Install the hello world handler. */
348
+ /* Install get all flags handler. */
367
349
clcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_core_module );
368
350
clcf -> handler = ngx_http_fs_sdk_get_all_flags_handler ;
369
351
@@ -401,10 +383,11 @@ static ngx_int_t ngx_http_fs_sdk_variable(ngx_http_request_t *r, ngx_http_variab
401
383
{
402
384
u_char * p ;
403
385
u_char * value ;
404
- ngx_http_fs_sdk_init_loc_conf_t * cglcf ;
405
386
char * flags ;
406
387
407
- #if FLAGSHIP_SDK_ENABLED
388
+ #if FLAGSHIP_SDK_ENABLED
389
+
390
+ ngx_http_fs_sdk_init_loc_conf_t * cglcf ;
408
391
409
392
initialize_flagship_sdk ("/usr/local/nginx/sbin/libflagship.so" , r );
410
393
@@ -424,11 +407,11 @@ static ngx_int_t ngx_http_fs_sdk_variable(ngx_http_request_t *r, ngx_http_variab
424
407
425
408
flags = get_all_flags ((char * )cglcf -> visitor_id .data , (char * )cglcf -> visitor_context .data );
426
409
427
- #else
410
+ #else
428
411
429
- flags = "Flagship sdk disabled"
412
+ flags = "Flagship sdk disabled" ;
430
413
431
- #endif
414
+ #endif
432
415
433
416
p = ngx_pnalloc (r -> pool , NGX_ATOMIC_T_LEN );
434
417
0 commit comments