- Remove possible back-to-back call of edg_wll_IncSequenceCode()
authorZdeněk Šustr <sustr4@cesnet.cz>
Wed, 30 Jun 2010 12:37:04 +0000 (12:37 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Wed, 30 Jun 2010 12:37:04 +0000 (12:37 +0000)
- Fix hard-coded resetting of error messages received from server.

org.glite.lb.client/src/producer.c

index 1f6e74f..b9616cd 100644 (file)
@@ -178,7 +178,6 @@ int edg_wll_DoLogEventServer(
                if ((ret = edg_wll_log_direct_connect(ctx,&con_bkserver))) {
                        edg_wll_UpdateError(ctx,EAGAIN,"edg_wll_DoLogEventServer(): edg_wll_log_direct_connect error");
                        goto edg_wll_DoLogEventServer_end;
-                       goto inc_seq_code;
                }
                count++;
        }
@@ -223,7 +222,7 @@ int edg_wll_DoLogEventServer(
                case 0: /* timeout */
                        edg_wll_UpdateError(ctx,EAGAIN,"edg_wll_DoLogEventServer(): select() timeouted");
                        count = 0;
-                       goto inc_seq_code
+                       goto edg_wll_DoLogEventServer_end
                        break;
                case -1: /* error */
                        switch(errno) {
@@ -231,7 +230,7 @@ int edg_wll_DoLogEventServer(
                                continue;
                        default:
                                edg_wll_UpdateError(ctx,errno,"edg_wll_DoLogEventServer(): select() error"); 
-                               goto inc_seq_code
+                               goto edg_wll_DoLogEventServer_end
                        }
                default:
                        break;
@@ -243,7 +242,7 @@ int edg_wll_DoLogEventServer(
                        /* read answer from lbproxy */
                        if ((ret = edg_wll_log_proxy_read(ctx,&con_lbproxy)) == -1) {
                                edg_wll_UpdateError(ctx,EAGAIN,"edg_wll_DoLogEventServer(): edg_wll_log_proxy_read error");
-                               goto inc_seq_code
+                               goto edg_wll_DoLogEventServer_end
                        }
                        count -= 1;
                }       
@@ -251,15 +250,12 @@ int edg_wll_DoLogEventServer(
                        /* read answer from bkserver */
                        if ((ret = edg_wll_log_direct_read(ctx,&con_bkserver)) == -1) {
                                edg_wll_UpdateError(ctx,EAGAIN,"edg_wll_DoLogEventServer(): edg_wll_log_direct_read error");
-                               goto inc_seq_code
+                               goto edg_wll_DoLogEventServer_end
                        }
                        count -= 1;
                }       
        }
 
-inc_seq_code:
-       edg_wll_IncSequenceCode(ctx);   /* XXX: should not fail, called second time */
-
 edg_wll_DoLogEventServer_end:
        edg_wll_log_proxy_close(ctx,&con_lbproxy);
        edg_wll_log_direct_close(ctx,&con_bkserver);
@@ -406,6 +402,8 @@ static int edg_wll_LogEventMasterVa(
 //     va_list fmt_args;
        int     ret = 0;
        edg_wll_LogLine in = NULL, out = NULL;
+        int     err_store;
+        char    *err_desc_store = NULL;
 
        if ((flags & (EDG_WLL_LOGFLAG_LOCAL|EDG_WLL_LOGFLAG_PROXY|EDG_WLL_LOGFLAG_DIRECT)) == 0) {
                return edg_wll_SetError(ctx,ret = EINVAL,"edg_wll_LogEventMaster(): no known flag specified");
@@ -448,10 +446,18 @@ edg_wll_logeventmaster_end:
        if (in) free(in);
        if (out) free(out);
 
-       if (!ret) if(edg_wll_IncSequenceCode(ctx)) {
+        if (ctx->errCode) { 
+                err_store = ctx->errCode;
+                err_desc_store = strdup(ctx->errDesc); }
+
+       if(edg_wll_IncSequenceCode(ctx)) {
                edg_wll_SetError(ctx,ret = EINVAL,"edg_wll_LogEventMaster(): edg_wll_IncSequenceCode failed");
        }
 
+       if (err_desc_store) {
+               edg_wll_SetError(ctx, err_store, err_desc_store);
+               free(err_desc_store); }
+
        if (ret) edg_wll_UpdateError(ctx,0,"Logging library ERROR: ");
 
        return edg_wll_Error(ctx,NULL,NULL);