Return timeout error instead of writing to unlocked event file
authorZdeněk Salvet <salvet@ics.muni.cz>
Wed, 15 Feb 2006 13:34:59 +0000 (13:34 +0000)
committerZdeněk Salvet <salvet@ics.muni.cz>
Wed, 15 Feb 2006 13:34:59 +0000 (13:34 +0000)
if all lock attempts failed. Don't sleep after last lock attempt.

org.glite.lb.common/src/log_msg.c

index eaf5d2f..595ed19 100644 (file)
@@ -143,7 +143,7 @@ int edg_wll_log_event_write(
                        case EAGAIN:
                        case EACCES:
                        case EINTR:
-                               sleep(fcntl_timeout);
+                               if ((i+1) < fcntl_attempts) sleep(fcntl_timeout);
                                break;
                        default:
                                edg_wll_SetError(ctx, errno, "fcntl()");
@@ -151,6 +151,10 @@ int edg_wll_log_event_write(
                        }
                } else break;
        }
+       if (i == fcntl_attempts) {
+               edg_wll_SetError(ctx, ETIMEDOUT, "timed out trying to lock event file");
+               goto cleanup;
+       }
 
        if ( fseek(outfile, 0, SEEK_END) == -1 ) {      
                edg_wll_SetError(ctx, errno, "fseek()");