#include <stdio.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "glite/security/glite_gsplugin.h"
#include "conf.h"
+#include "db_ops.h"
#include "soap_ps_calls.h"
#include "soap_version.h"
static int debug = 1;
static glite_jp_context_t ctx;
-
-//static int call_opts(glite_jp_context_t,char *,char *,int (*)(glite_jp_context_t,int,char **));
-
-char *glite_jp_default_namespace;
-
+static char *glite_jp_default_namespace;
+static glite_jp_is_conf *conf; // Let's make configuration visible to all slaves
int main(int argc, char *argv[])
int one = 1,opt,i;
edg_wll_GssStatus gss_code;
struct sockaddr_in a;
- glite_jp_is_conf *conf;
char *config_file;
fprintf(stderr,"Server idenity: %s\n",mysubj);
else fputs("WARNING: Running unauthenticated\n",stderr);
- // ask PS server for data
- // XXX: should come after glite_srvbones_run(), when listening
- for (i=0; conf->PS_list[i]; i++)
- MyFeedIndex(conf,conf->PS_list[i]);
-
/* XXX: daemonise */
glite_srvbones_set_param(GLITE_SBPARAM_SLAVES_COUNT,1);
return 0;
}
+/* slave's init comes here */
static int data_init(void **data)
{
- *data = (void *) soap_new();
+ char *PS_URL = NULL;
- printf("[%d] slave started\n",getpid());
- /* slave's init comes here */
+ *data = (void *) soap_new();
+ printf("[%d] slave started\n",getpid());
- return 0;
+ /* ask PS server for data */
+ do {
+ switch (glite_jpis_lockUninitializedFeed(&PS_URL)) {
+ case ENOENT:
+ // no more feeds to initialize
+ return 0;
+ case ENOLCK:
+ // error during locking
+ printf("[%d] slave_init(): Locking error.\n",getpid());
+ free(PS_URL);
+ return -1;
+ default:
+ // contact PS server, ask for data, save feedId and expiration
+ // to DB and unlock feed
+ MyFeedIndex(conf, PS_URL);
+ free(PS_URL);
+ PS_URL = NULL;
+ break;
+ }
+ } while (1);
}
static int newconn(int conn,struct timeval *to,void *data)
--- /dev/null
+#ident "$Header$"
+
+#include <time.h>
+
+/* Find first unitialized feed, lock it and return URL of corresponding PS
+ *
+ * Return value:
+ * 0 - OK
+ * ENOENT - no more feeds to initialize
+ * ENOLCK - error during locking */
+
+int glite_jpis_lockUninitializedFeed(char **PS_URL)
+{
+ return 0;
+}
+
+
+/* Store feed ID and expiration time returned by PS for locked feed. */
+
+void glite_jpis_feedInit(char *PS_URL, char *feedId, time_t feedExpires)
+{
+}
+
+/* Unlock given feed */
+
+void glite_jpis_unlockFeed(char *PS_URL)
+{
+}
+
#include "soap_version.h"
#include "conf.h"
+#include "db_ops.h"
#include "stdsoap2.h"
//if (!check_fault(soap,soap_call_jpsrv___FeedIndex(soap,dest,"",
if (soap_call___jpsrv__FeedIndex(soap,dest,"", &in, &out)) {
printf("soap_call___jpsrv__FeedIndex() returned error\n");
+ glite_jpis_unlockFeed(dest);
goto err;
}
- else
+ else {
printf("FeedId: %s\nExpires: %s\n",out.feedId,ctime(&out.feedExpires));
+ glite_jpis_feedInit(dest, out.feedId, out.feedExpires);
+ glite_jpis_unlockFeed(dest);
+ }
err:
soap_end(soap);