From d23802890d43f07418f98f6e6d7f7505f5d35707 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Tue, 4 Oct 2005 13:58:34 +0000 Subject: [PATCH] preliminary support for IS to PS connection error handling --- org.glite.jp.index/src/bones_server.c | 11 +++++++++-- org.glite.jp.index/src/db_ops.c | 7 +++++++ org.glite.jp.index/src/db_ops.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/org.glite.jp.index/src/bones_server.c b/org.glite.jp.index/src/bones_server.c index 3f9280f..92dc535 100644 --- a/org.glite.jp.index/src/bones_server.c +++ b/org.glite.jp.index/src/bones_server.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "glite/jp/types.h" #include "glite/jp/context.h" @@ -31,6 +32,9 @@ #define USER_QUERY_SLAVES_NUM 2 // # of slaves reserved for user queries if // # PS to conntact is << MAX_SLAVES_NUM +#define RECONNECT_TIME 60*20 // when try reconnect to PS in case of error (in sec) + + extern SOAP_NMAC struct Namespace jpis__namespaces[],jpps__namespaces[]; extern SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} }; // namespaces[] not used here, but need to prevent linker to complain... @@ -199,14 +203,17 @@ static int data_init(void **data) free(PS_URL); glite_jpis_free_context(private->ctx); return -1; + case ENOTCONN: + // error when connecting to PS + glite_jpis_tryReconnectFeed(private->ctx, uniqueid, + time(NULL) + RECONNECT_TIME); + break; default: // contact PS server, ask for data, save feedId and expiration // to DB and unlock feed MyFeedIndex(private->ctx, conf, uniqueid, PS_URL); free(PS_URL); PS_URL = NULL; -// FIXME: infinite retrying on fail ==> fast increasing of used resources - sleep(2); break; } } while (1); diff --git a/org.glite.jp.index/src/db_ops.c b/org.glite.jp.index/src/db_ops.c index 402b983..71fc6da 100644 --- a/org.glite.jp.index/src/db_ops.c +++ b/org.glite.jp.index/src/db_ops.c @@ -535,6 +535,13 @@ int glite_jpis_unlockFeed(glite_jpis_context_t ctx, long int uniqueid) { } +/* Saves TTL (when to reconnect if error occured) for given feed */ + +void glite_jpis_tryReconnectFeed(glite_jpis_context_t ctx, long int uniqueid, time_t reconn_time) { + +} + + int glite_jpis_insertAttrVal(glite_jpis_context_t ctx, const char *jobid, glite_jp_attrval_t *av) { char *sql, *table, *value, *full_value; diff --git a/org.glite.jp.index/src/db_ops.h b/org.glite.jp.index/src/db_ops.h index ed3e78c..42284b5 100644 --- a/org.glite.jp.index/src/db_ops.h +++ b/org.glite.jp.index/src/db_ops.h @@ -36,6 +36,7 @@ void glite_jpis_free_context(glite_jpis_context_t ctx); int glite_jpis_lockUninitializedFeed(glite_jpis_context_t ctx, long int *uinqueid, char **PS_URL); int glite_jpis_initFeed(glite_jpis_context_t ctx, long int uniqueid, char *feedId, time_t feedExpires); int glite_jpis_unlockFeed(glite_jpis_context_t ctx, long int uniqueid); +void glite_jpis_tryReconnectFeed(glite_jpis_context_t ctx, long int uniqueid, time_t reconn_time); int glite_jpis_insertAttrVal(glite_jpis_context_t ctx, const char *jobid, glite_jp_attrval_t *av); -- 1.8.2.3