Web services faults fixes:
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 23 Apr 2007 17:12:20 +0000 (17:12 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 23 Apr 2007 17:12:20 +0000 (17:12 +0000)
 - small bug in robustness in JP for gsoaps <= 2.7.6
 - ugly random bug on LB server for gsoap >= 2.7.9 (HEAD problem only)
 - implemented __any fallback (for newer clients and older server) in LB server too
Leaks in LB ws_joblog example.

org.glite.jp.ws-interface/src/ws_fault.c
org.glite.lb.server/examples/ws_joblog.c
org.glite.lb.server/src/ws_fault.c

index 4f02a6d..1d62782 100644 (file)
@@ -120,19 +120,19 @@ static struct jptype__genericFault* jp2s_error(struct soap *soap, const glite_jp
 static void glite_jp_server_err2fault(const glite_jp_context_t ctx,struct soap *soap)
 {
        struct SOAP_ENV__Detail *detail;
+       struct jptype__genericFault *item;
 #if GSOAP_VERSION >= 20709
        struct jptype__genericFault *f;
-       f = jp2s_error(soap,ctx->error);
+       item = f = jp2s_error(soap,ctx->error);
 #else
        struct _genericFault *f = soap_malloc(soap, sizeof *f);
-       f->jpelem__genericFault = jp2s_error(soap,ctx->error);
+       item = f->jpelem__genericFault = jp2s_error(soap,ctx->error);
 #endif
        soap_receiver_fault(soap,"Oh, shit!",NULL);
        // no error in JP context?
-       if (!f) return;
+       if (!item) return;
 
-       detail = soap_malloc(soap,sizeof *detail);
-       memset(detail, 0, sizeof(*detail));
+       detail = soap_faultdetail(soap);
 #if GSOAP_VERSION >= 20700
        detail->fault = (void *)f;
 #else
@@ -140,7 +140,4 @@ static void glite_jp_server_err2fault(const glite_jp_context_t ctx,struct soap *
 #endif
        detail->__type = GFNUM;
        detail->__any = NULL;
-
-       if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail;
-       else soap->fault->detail = detail;
 }
index a3bff54..a369178 100644 (file)
@@ -112,9 +112,14 @@ int main(int argc,char** argv)
        memset(&in, 0, sizeof in);
        memset(&out, 0, sizeof out);
 
+       soap_begin(mydlo);
        if (edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)jconds,
                        &in.__sizejobConditions, &in.jobConditions) != SOAP_OK) {
                printf("Error converting QueryConds to Soap!\n");
+               soap_end(mydlo);
+               soap_done(mydlo);
+               glite_gsplugin_free_context(gsplugin_ctx);
+               edg_wll_FreeContext(ctx);
                return(1);
        }
 
@@ -162,7 +167,10 @@ int main(int argc,char** argv)
                edg_wll_FaultToErr(mydlo,ctx);
                edg_wll_Error(ctx,&et,&ed);
                fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed);
-               soap_done(mydlo);
+               soap_end(mydlo);
+               soap_done(mydlo); free(mydlo);
+               glite_gsplugin_free_context(gsplugin_ctx);
+               edg_wll_FreeContext(ctx);
                exit(1);
                }
        default:
index de0b638..2d76c96 100644 (file)
@@ -18,7 +18,7 @@
 void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap)
 {
        char    *et,*ed;
-       struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail);
+       struct SOAP_ENV__Detail *detail;
 #if GSOAP_VERSION >= 20709
        struct lbt__genericFault *f = soap_malloc(soap,sizeof *f);
        struct lbt__genericFault *item = f;
@@ -39,6 +39,7 @@ void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap)
                free(ed);
        }
 
+       detail = soap_faultdetail(soap);
        detail->__type = GFNUM;
 #if GSOAP_VERSION >= 20700
        detail->fault = f;
@@ -66,7 +67,7 @@ void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx)
        detail = soap->version == 2 ? soap->fault->SOAP_ENV__Detail : soap->fault->detail;
        if (detail->__type == GFNUM) {
 #if GSOAP_VERSION >= 20709
-               f = detail->lbe__genericFault;
+               f = (struct lbt__genericFault *)detail->fault;
 #elif GSOAP_VERSION >= 20700
                f = ((struct _genericFault *) detail->fault)
                        ->lbe__genericFault;
@@ -74,12 +75,14 @@ void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx)
                f = ((struct _genericFault *) detail->value)
                        ->lbe__genericFault;
 #endif
-               edg_wll_SetError(ctx,f->code,f->description);
+               if (f) edg_wll_SetError(ctx,f->code,f->description);
+               else edg_wll_SetError(ctx, EIO, "no or not parsable error from SOAP");
        }
        else {
                char    *s;
 
-               asprintf(&s,"SOAP: %s", soap->version == 2 ?
+               if (detail->__any) asprintf(&s, "SOAP: %s", detail->__any);
+               else asprintf(&s,"SOAP: %s", soap->version == 2 ?
                        GLITE_SECURITY_GSOAP_REASON(soap) : soap->fault->faultstring);
                edg_wll_SetError(ctx,EINVAL,s);
                free(s);