From 99dd207c9644a1f9f1d598027ffe6732f934cd4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20Salvet?= Date: Wed, 28 May 2008 10:16:12 +0000 Subject: [PATCH] Don't try to close non-existent connection in case of connect error. Reconnect and retry sending event once when logd closes connection (this normal situation, not a real error). --- org.glite.lb.client/src/producer.c | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index 0032513..80e59bc 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -88,32 +88,36 @@ int edg_wll_DoLogEvent( edg_wll_LogLine logline) { int ret = 0, answer = EAGAIN; - int conn; + int conn = -1; + int attempt = 1; edg_wll_ResetError(ctx); memset(&conn,0,sizeof(conn)); - /* connect to local-logger */ - if ((ret = edg_wll_log_connect(ctx,&conn))) { - edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_connect error"); - goto edg_wll_DoLogEvent_end; - } - - /* send message */ - if ((ret = edg_wll_log_write(ctx,conn,logline)) == -1) { - edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_write error"); - goto edg_wll_DoLogEvent_end; - } - - /* get answer */ - if ((ret = edg_wll_log_read(ctx,conn)) == -1) { - edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_read error"); - } else { + do { + /* connect to local-logger */ + if ((ret = edg_wll_log_connect(ctx,&conn))) { + edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_connect error"); + goto edg_wll_DoLogEvent_end; + } + + /* send message */ + if ((ret = edg_wll_log_write(ctx,conn,logline)) == -1) { + answer = edg_wll_Error(ctx, NULL, NULL); + edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_write error"); + goto edg_wll_DoLogEvent_end; + } + + /* get answer */ + ret = edg_wll_log_read(ctx,conn); answer = edg_wll_Error(ctx, NULL, NULL); - } + if (ret == -1) + edg_wll_UpdateError(ctx,EDG_WLL_IL_PROTO,"edg_wll_DoLogEvent(): edg_wll_log_read error"); + + edg_wll_DoLogEvent_end: + if (ret == -1 && conn >= 0) edg_wll_log_close(ctx,conn); -edg_wll_DoLogEvent_end: - if (ret) edg_wll_log_close(ctx,conn); + } while (++attempt <= 2 && (answer == ENOTCONN || answer == EPIPE)); return handle_errors(ctx,answer,"edg_wll_DoLogEvent()"); } -- 1.8.2.3