46 #define fabs(v) ((v) < 0.0 ? -(v) : (v))
48 #define NCBI_USE_ERRCODE_X Connect_LBSM
51 #define DISPD_STALE_RATIO_OK 0.8
53 #define DISPD_LOCAL_BONUS 1.2
91 for (
n = 0;
n <
data->n_cand; ++
n) {
104 n =
data->a_cand + 10;
106 ? realloc(
data->cand,
n *
sizeof(*temp))
107 :
malloc (
n *
sizeof(*temp)));
133 if (server_error == 400 || server_error == 403 || server_error == 404)
135 data->code = server_error;
136 }
else if (sscanf(header,
"%*s %d", &
data->code) < 1) {
160 return data->fail ? 0 : 1;
183 ?
"Dispatch-Mode: PROMISCUOUS\r\n"
185 ?
"Dispatch-Mode: OK_DOWN\r\n"
187 ?
"Dispatch-Mode: OK_SUPPRESSED\r\n"
188 :
"Dispatch-Mode: INFORMATION_ONLY\r\n")
191 ?
"Client-Mode: REVERSE_DNS\r\n"
193 ?
"Client-Mode: STATEFUL_CAPABLE\r\n"
194 :
"Client-Mode: STATELESS_ONLY\r\n")) {
210 (
"[%s] Unable to create %s network dispatcher%s%s%s: %s",
211 iter->
name, c ?
"connection to" :
"connector for",
212 url ?
" at \"" :
"", url ? url :
"", &
"\""[!url],
218 else if (c && c->destroy)
226 static const char server_info[] =
"Server-Info-";
231 &&
isdigit((
unsigned char)
text[
sizeof(server_info) - 1])) {
238 text +=
sizeof(server_info) - 1;
239 if (sscanf(
text,
"%u: %n", &d1, &d2) < 1 || d1 < 1)
246 while (*name &&
isspace((
unsigned char)(*name)))
252 for (c = s + (name - s); *c; ++c) {
253 if (
isspace((
unsigned char)(*c)))
278 #if defined(_DEBUG) && !defined(NDEBUG)
279 if (
data->net_info->debug_printout) {
301 double status = 0.0, total = 0.0;
305 while (i < data->
n_cand) {
308 if (
info->time < now) {
355 (
data->n_cand -
n) *
sizeof(*
data->cand));
373 for (
i = 0;
i <
data->n_cand; ++
i)
416 data->net_info->stateless = 1;
421 "User-Agent: NCBIServiceDispatcher/"
441 || !(
data->net_info->stateless &&
442 data->net_info->firewall))) {
444 (
"SERV_DISPD_Open(\"%s\"): Service not found", iter->
name));
static CS_CONNECTION * conn
CONNECTOR HTTP_CreateConnectorEx(const SConnNetInfo *net_info, THTTP_Flags flags, FHTTP_ParseHeader parse_header, void *user_data, FHTTP_Adjust adjust, FHTTP_Cleanup cleanup)
Create new CONNECTOR structure to hit the specified URL using HTTP with either POST / GET (or ANY) me...
EIO_Status CONN_Flush(CONN conn)
Explicitly flush connection from any pending data written by CONN_Write().
EIO_Status CONN_Create(CONNECTOR connector, CONN *conn)
Same as CONN_CreateEx() called with 0 in the "flags" parameter.
EHTTP_HeaderParse
The extended version HTTP_CreateConnectorEx() is able to track the HTTP response chain and also chang...
EIO_Status CONN_Close(CONN conn)
Close the connection and destroy all relevant internal data.
@ fHTTP_Flushable
Connector will really flush on Flush()
@ eHTTP_HeaderSuccess
Parse succeeded, retain server status.
@ eHTTP_HeaderError
Parse failed, treat as a server error.
struct SSERV_IterTag * SERV_ITER
Iterator through the servers.
int SERV_EqualInfo(const SSERV_Info *info1, const SSERV_Info *info2)
@ fSERV_Stateless
Stateless servers only.
int ConnNetInfo_ExtendUserHeader(SConnNetInfo *net_info, const char *header)
int ConnNetInfo_SetupStandardArgs(SConnNetInfo *net_info, const char *service)
int ConnNetInfo_OverrideUserHeader(SConnNetInfo *net_info, const char *header)
SConnNetInfo * ConnNetInfo_Clone(const SConnNetInfo *net_info)
#define NCBI_TIME_INFINITE
char * ConnNetInfo_URL(const SConnNetInfo *net_info)
const char * IO_StatusStr(EIO_Status status)
Get the text form of an enum status value.
void ConnNetInfo_DeleteUserHeader(SConnNetInfo *net_info, const char *header)
void ConnNetInfo_Destroy(SConnNetInfo *net_info)
@ eIO_Success
everything is fine, no error occurred
@ eIO_Unknown
unknown I/O error (likely fatal but can retry)
@ eFWMode_Adaptive
Regular firewall ports first, then fallback.
unsigned int
A callback function used to compare two keys in a database.
if(yy_accept[yy_current_state])
static const CS_INT unused
static void text(MDB_val *v)
#define NCBI_DISP_VERSION
#define HTTP_DISP_FAILURES
#define HTTP_DISP_MESSAGES
#define DISPD_LOCAL_BONUS
static int s_IsUpdateNeeded(struct SDISPD_Data *data, TNCBI_Time now)
static SLB_Candidate * s_GetCandidate(void *user_data, size_t n)
static void s_Close(SERV_ITER)
static void s_Reset(SERV_ITER)
#define DISPD_STALE_RATIO_OK
static int s_Adjust(SConnNetInfo *net_info, void *iter, unsigned int unused)
static SSERV_Info * s_GetNextInfo(SERV_ITER, HOST_INFO *)
static int s_Update(SERV_ITER, const char *, int)
const SSERV_VTable * SERV_DISPD_Open(SERV_ITER iter, const SConnNetInfo *net_info, SSERV_Info **info)
static EHTTP_HeaderParse s_ParseHeader(const char *header, void *user_data, int server_error)
static int s_AddServerInfo(struct SDISPD_Data *data, SSERV_Info *info)
static void s_Resolve(SERV_ITER iter)
static const SSERV_VTable kDispdOp
size_t LB_Select(SERV_ITER iter, void *data, FGetCandidate get_candidate, double bonus)
unsigned int g_NCBI_ConnectRandomSeed
#define CORE_LOGF_X(subcode, level, fmt_args)
#define NCBI_CONNECT_SRAND_ADDEND
#define CORE_LOGF(level, fmt_args)
SSERV_Info * SERV_ReadInfoEx(const char *str, const char *name, int lazy)
const char * SERV_NameOfInfo(const SSERV_Info *info)
int SERV_Update(SERV_ITER iter, const char *text, int code)
char * SERV_Print(SERV_ITER iter, const SConnNetInfo *net_info, int but_last)
voidp calloc(uInt items, uInt size)