trivial client to reproduce bug #18994
authorAleš Křenek <ljocha@ics.muni.cz>
Mon, 14 Aug 2006 09:04:36 +0000 (09:04 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Mon, 14 Aug 2006 09:04:36 +0000 (09:04 +0000)
org.glite.lb.client/Makefile
org.glite.lb.client/examples/flood_proxy.c [new file with mode: 0644]

index e25e248..d4de6b3 100644 (file)
@@ -132,7 +132,7 @@ PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la
 THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la
 
 TOOLS:=dump load purge lb_dump_exporter
-EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl lbmon
+EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl lbmon flood_proxy
 
 EXAMPLES_CL=user_jobs job_status
 FAKE_EXAMPLES:=job_log_fake
diff --git a/org.glite.lb.client/examples/flood_proxy.c b/org.glite.lb.client/examples/flood_proxy.c
new file mode 100644 (file)
index 0000000..91c7f8a
--- /dev/null
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "glite/lb/producer.h"
+#include "glite/wmsutils/jobid/cjobid.h"
+
+static void slave();
+
+int main(int argc,char **argv)
+{
+       int     i,njobs,nproc;
+
+       if (argc != 2) {
+               fprintf(stderr,"usage: %s nproc\n",argv[0]);
+               return 1;
+       }
+       
+       nproc = atoi(argv[1]);
+       if (nproc < 1) {
+               fprintf(stderr,"%s: nproc must be >= 1\n",argv[0]);
+               return 1;
+       }
+
+       for (i=0; i<nproc; i++) {
+               switch (fork()) {
+                       case -1: perror("fork()"); return 1;
+                       case 0: slave();
+                       default: break;
+               }
+       }
+
+       while (nproc) {
+               int     stat;
+               wait(&stat);
+               if (WIFEXITED(stat)) nproc--;
+       }
+
+       puts("done");
+       return 0;
+}
+
+
+static void slave()
+{
+       edg_wll_Context ctx;
+       edg_wlc_JobId   job;
+       int     i,pid = getpid(),noent = 0;
+
+       for (i=0; i<100; i++) {
+               int     err;
+               char    *et,*ed;
+
+               edg_wll_InitContext(&ctx);
+               edg_wlc_JobIdParse("https://fake.server/fakejob",&job);
+
+               if ((err = edg_wll_SetLoggingJobProxy(ctx,job,NULL,"some user",0))) edg_wll_Error(ctx,&et,&ed);
+               else et = ed = "none";
+
+               printf("[%d] %d: %s (%s)\n",pid,i,
+                               err == 0 || err == ENOENT ? "OK" : et,
+                               ed);
+
+               if (err == ENOENT) noent++;
+
+               edg_wll_FreeContext(ctx);
+       }
+       printf("[%d] done, ENOENTs %d\n",pid,noent);
+       exit(0);
+}