job_reg working
authorMiloš Mulač <mulac@civ.zcu.cz>
Mon, 18 Feb 2008 16:44:00 +0000 (16:44 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Mon, 18 Feb 2008 16:44:00 +0000 (16:44 +0000)
org.glite.lb.server/src/query.c
org.glite.lb.server/src/store.c.T

index e0279de..29902a6 100644 (file)
@@ -54,7 +54,7 @@ int edg_wll_QueryEventsServer(
                                   *event_where = NULL,
                                   *qbase = NULL,
                                   *q = NULL,
-                                  *res[11];
+                                  *res[12];
        edg_wll_Event  *out = NULL;
        glite_lbu_Statement     sh = NULL;
        int                             i = 0,
@@ -103,7 +103,7 @@ int edg_wll_QueryEventsServer(
  * convert_event_head() called on the result
  */
        trio_asprintf(&qbase,"SELECT e.event,j.userid,j.dg_jobid,e.code,"
-               "e.prog,e.host,u.cert_subj,e.time_stamp,e.usec,e.level,e.arrived "
+               "e.prog,e.host,u.cert_subj,e.time_stamp,e.usec,e.level,e.arrived,e.seqcode "
                "FROM events e,users u,jobs j%s "
                "WHERE %se.jobid=j.jobid AND e.userid=u.userid AND e.code != %d "
                "%s %s %s %s %s %s",
@@ -1286,6 +1286,9 @@ int convert_event_head(edg_wll_Context ctx,char **f,edg_wll_Event *e)
        e->any.arrived.tv_usec = 0;
        free(f[8]); f[8] = NULL;
 
+       e->any.seqcode = f[9];
+       f[9] = NULL;
+
        return 0;
 
 err:
index bcfe1e7..fc15e27 100644 (file)
@@ -93,14 +93,14 @@ int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,int
 /* check duplicity */
        trio_asprintf(&stmt,
                "select arrived from events where jobid='%|Ss' and code='%d'"
-               " and prog='%|Ss' and host='%|Ss' and time_stamp='%s' and usec='%d'"
-               " and level='%d' and userid='%|Ss' and seqcode='%|Ss'",
+               " and prog='%|Ss' and host='%|Ss' and time_stamp=%s and usec='%d'"
+               " and level='%d' and userid='%|Ss' and seqcode='%|Ss'",
                jobid, (int) e->any.type,
                ssrc,e->any.host,
                stamp,e->any.timestamp.tv_usec,
                e->any.level,userid, e->any.seqcode);
 
-       if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto clean;
+       if (edg_wll_ExecSQL(ctx,stmt,&sh) < 0) goto clean;
        nr = edg_wll_FetchRow(ctx,sh,1,NULL,&dummy);
        if (sh) glite_lbu_FreeStmt(&sh);
        free(stmt); stmt = NULL;
@@ -285,7 +285,10 @@ int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *regis
 
        trio_asprintf(&q,"select proxy,server,grey from jobs where jobid='%|Ss' for update", event->any.jobId);
 
-       if ( (nar = edg_wll_ExecSQL(ctx,q,&stmt)) < 0 ) {
+       nar = edg_wll_ExecSQL(ctx,q,&stmt);
+
+       if (nar < 0) goto err;
+       else if (nar == 0) {
                /* Job not registered yet */
 
                if (!( (event->any.type == EDG_WLL_EVENT_REGJOB) && 
@@ -343,7 +346,7 @@ int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *regis
        }
 
 err:
-       free(res[0]); free(res[1]); free(res[3]);
+       free(res[0]); free(res[1]); free(res[2]);
        if (stmt) glite_lbu_FreeStmt(&stmt);
        free(subj);
        free(userid);