[mod_proxy] move data_fastcgi into mod_proxy.c
(data_fastcgi is used only by mod_proxy at this point)personal/stbuehler/mod-csrf
parent
f3437fb2f2
commit
9b9f445a7b
|
@ -545,7 +545,7 @@ set(COMMON_SRC
|
|||
http_chunk.c stream.c fdevent.c
|
||||
stat_cache.c plugin.c joblist.c etag.c array.c
|
||||
data_string.c data_array.c
|
||||
data_integer.c md5.c data_fastcgi.c
|
||||
data_integer.c md5.c
|
||||
vector.c
|
||||
fdevent_select.c fdevent_libev.c
|
||||
fdevent_poll.c fdevent_linux_sysepoll.c
|
||||
|
|
|
@ -60,7 +60,7 @@ common_src=base64.c buffer.c log.c \
|
|||
http_chunk.c stream.c fdevent.c \
|
||||
stat_cache.c plugin.c joblist.c etag.c array.c \
|
||||
data_string.c data_array.c \
|
||||
data_integer.c md5.c data_fastcgi.c \
|
||||
data_integer.c md5.c \
|
||||
vector.c \
|
||||
fdevent_select.c fdevent_libev.c \
|
||||
fdevent_poll.c fdevent_linux_sysepoll.c \
|
||||
|
|
|
@ -54,7 +54,7 @@ common_src = Split("base64.c buffer.c log.c \
|
|||
http_chunk.c stream.c fdevent.c \
|
||||
stat_cache.c plugin.c joblist.c etag.c array.c \
|
||||
data_string.c data_array.c \
|
||||
data_integer.c md5.c data_fastcgi.c \
|
||||
data_integer.c md5.c \
|
||||
vector.c \
|
||||
fdevent_select.c fdevent_libev.c \
|
||||
fdevent_poll.c fdevent_linux_sysepoll.c \
|
||||
|
|
19
src/array.h
19
src/array.h
|
@ -13,7 +13,7 @@
|
|||
|
||||
#define DATA_IS_STRING(x) (x->type == TYPE_STRING)
|
||||
|
||||
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_OTHER, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
|
||||
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_OTHER, TYPE_ARRAY, TYPE_INTEGER, TYPE_DONOTUSE, TYPE_CONFIG } data_type_t;
|
||||
#define DATA_UNSET \
|
||||
data_type_t type; \
|
||||
buffer *key; \
|
||||
|
@ -134,23 +134,6 @@ typedef struct {
|
|||
|
||||
data_integer *data_integer_init(void);
|
||||
|
||||
typedef struct {
|
||||
DATA_UNSET;
|
||||
|
||||
buffer *host;
|
||||
|
||||
unsigned short port;
|
||||
|
||||
time_t disable_ts;
|
||||
int is_disabled;
|
||||
size_t balance;
|
||||
|
||||
int usage; /* fair-balancing needs the no. of connections active on this host */
|
||||
int last_used_ndx; /* round robin */
|
||||
} data_fastcgi;
|
||||
|
||||
data_fastcgi *data_fastcgi_init(void);
|
||||
|
||||
array *array_init(void);
|
||||
array *array_init_array(array *a);
|
||||
void array_free(array *a);
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
#include "first.h"
|
||||
|
||||
#include "array.h"
|
||||
#include "fastcgi.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static data_unset *data_fastcgi_copy(const data_unset *s) {
|
||||
data_fastcgi *src = (data_fastcgi *)s;
|
||||
data_fastcgi *ds = data_fastcgi_init();
|
||||
|
||||
buffer_copy_buffer(ds->key, src->key);
|
||||
buffer_copy_buffer(ds->host, src->host);
|
||||
ds->is_index_key = src->is_index_key;
|
||||
return (data_unset *)ds;
|
||||
}
|
||||
|
||||
static void data_fastcgi_free(data_unset *d) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
|
||||
buffer_free(ds->key);
|
||||
buffer_free(ds->host);
|
||||
|
||||
free(d);
|
||||
}
|
||||
|
||||
static void data_fastcgi_reset(data_unset *d) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
|
||||
buffer_reset(ds->key);
|
||||
buffer_reset(ds->host);
|
||||
|
||||
}
|
||||
|
||||
static int data_fastcgi_insert_dup(data_unset *dst, data_unset *src) {
|
||||
UNUSED(dst);
|
||||
|
||||
src->free(src);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void data_fastcgi_print(const data_unset *d, int depth) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
UNUSED(depth);
|
||||
|
||||
fprintf(stdout, "fastcgi(%s)", ds->host->ptr);
|
||||
}
|
||||
|
||||
|
||||
data_fastcgi *data_fastcgi_init(void) {
|
||||
data_fastcgi *ds;
|
||||
|
||||
ds = calloc(1, sizeof(*ds));
|
||||
force_assert(NULL != ds);
|
||||
|
||||
ds->key = buffer_init();
|
||||
ds->host = buffer_init();
|
||||
ds->port = 0;
|
||||
ds->is_disabled = 0;
|
||||
|
||||
ds->copy = data_fastcgi_copy;
|
||||
ds->free = data_fastcgi_free;
|
||||
ds->reset = data_fastcgi_reset;
|
||||
ds->insert_dup = data_fastcgi_insert_dup;
|
||||
ds->print = data_fastcgi_print;
|
||||
ds->type = TYPE_FASTCGI;
|
||||
|
||||
return ds;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#include "first.h"
|
||||
|
||||
#include "array.h"
|
||||
#include "buffer.h"
|
||||
#include "server.h"
|
||||
#include "keyvalue.h"
|
||||
|
@ -26,9 +27,99 @@
|
|||
|
||||
#include "sys-socket.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#define data_proxy data_fastcgi
|
||||
#define data_proxy_init data_fastcgi_init
|
||||
|
||||
|
||||
typedef struct {
|
||||
DATA_UNSET;
|
||||
|
||||
buffer *host;
|
||||
|
||||
unsigned short port;
|
||||
|
||||
time_t disable_ts;
|
||||
int is_disabled;
|
||||
size_t balance;
|
||||
|
||||
int usage; /* fair-balancing needs the no. of connections active on this host */
|
||||
int last_used_ndx; /* round robin */
|
||||
} data_fastcgi;
|
||||
|
||||
static data_fastcgi *data_fastcgi_init(void);
|
||||
|
||||
|
||||
static data_unset *data_fastcgi_copy(const data_unset *s) {
|
||||
data_fastcgi *src = (data_fastcgi *)s;
|
||||
data_fastcgi *ds = data_fastcgi_init();
|
||||
|
||||
buffer_copy_buffer(ds->key, src->key);
|
||||
buffer_copy_buffer(ds->host, src->host);
|
||||
ds->is_index_key = src->is_index_key;
|
||||
return (data_unset *)ds;
|
||||
}
|
||||
|
||||
static void data_fastcgi_free(data_unset *d) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
|
||||
buffer_free(ds->key);
|
||||
buffer_free(ds->host);
|
||||
|
||||
free(d);
|
||||
}
|
||||
|
||||
static void data_fastcgi_reset(data_unset *d) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
|
||||
buffer_reset(ds->key);
|
||||
buffer_reset(ds->host);
|
||||
|
||||
}
|
||||
|
||||
static int data_fastcgi_insert_dup(data_unset *dst, data_unset *src) {
|
||||
UNUSED(dst);
|
||||
|
||||
src->free(src);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <stdio.h> /* fprintf() */
|
||||
static void data_fastcgi_print(const data_unset *d, int depth) {
|
||||
data_fastcgi *ds = (data_fastcgi *)d;
|
||||
UNUSED(depth);
|
||||
|
||||
fprintf(stdout, "fastcgi(%s)", ds->host->ptr);
|
||||
}
|
||||
|
||||
|
||||
static data_fastcgi *data_fastcgi_init(void) {
|
||||
data_fastcgi *ds;
|
||||
|
||||
ds = calloc(1, sizeof(*ds));
|
||||
force_assert(NULL != ds);
|
||||
|
||||
ds->key = buffer_init();
|
||||
ds->host = buffer_init();
|
||||
ds->port = 0;
|
||||
ds->is_disabled = 0;
|
||||
|
||||
ds->copy = data_fastcgi_copy;
|
||||
ds->free = data_fastcgi_free;
|
||||
ds->reset = data_fastcgi_reset;
|
||||
ds->insert_dup = data_fastcgi_insert_dup;
|
||||
ds->print = data_fastcgi_print;
|
||||
ds->type = TYPE_OTHER;
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define PROXY_RETRY_TIMEOUT 60
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue