From: Jiří Škrábal Date: Mon, 11 Apr 2005 13:23:17 +0000 (+0000) Subject: - do not reopen the file when could not lock it X-Git-Tag: gridsite-core_R_1_1_8~24 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=1b9f41b9e54be50325130468fa6023ae070a6bcd;p=jra1mw.git - do not reopen the file when could not lock it --- diff --git a/org.glite.lb.common/src/log_msg.c b/org.glite.lb.common/src/log_msg.c index ea6260b..d495cbf 100644 --- a/org.glite.lb.common/src/log_msg.c +++ b/org.glite.lb.common/src/log_msg.c @@ -112,18 +112,18 @@ int edg_wll_log_event_write( i, filelock_status=-1; - for ( i = 0; i < fcntl_attempts; i++ ) { - if ( (outfile = fopen(event_file, "a")) == NULL ) { - edg_wll_SetError(ctx, errno, "fopen()"); - goto event_write_end; - } + if ( (outfile = fopen(event_file, "a")) == NULL ) { + edg_wll_SetError(ctx, errno, "fopen()"); + goto event_write_end; + } - if ( (filedesc = fileno(outfile)) == -1 ) { - edg_wll_SetError(ctx, errno, "fileno()"); - fclose(outfile); - goto cleanup; - } + if ( (filedesc = fileno(outfile)) == -1 ) { + edg_wll_SetError(ctx, errno, "fileno()"); + fclose(outfile); + goto cleanup; + } + for ( i = 0; i < fcntl_attempts; i++ ) { filelock.l_type = F_WRLCK; filelock.l_whence = SEEK_SET; filelock.l_start = 0; @@ -140,7 +140,7 @@ int edg_wll_log_event_write( edg_wll_SetError(ctx, errno, "fcntl()"); goto cleanup; } - } + } else break; } if ( fseek(outfile, 0, SEEK_END) == -1 ) {