preliminary support for IS to PS connection error handling
authorMiloš Mulač <mulac@civ.zcu.cz>
Tue, 4 Oct 2005 13:58:34 +0000 (13:58 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Tue, 4 Oct 2005 13:58:34 +0000 (13:58 +0000)
org.glite.jp.index/src/bones_server.c
org.glite.jp.index/src/db_ops.c
org.glite.jp.index/src/db_ops.h

index 3f9280f..92dc535 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <unistd.h>
+#include <time.h>
 
 #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);
index 402b983..71fc6da 100644 (file)
@@ -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;
 
index ed3e78c..42284b5 100644 (file)
@@ -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);