Browse code

proper clean-up for failed opening of reply fifo done

Jiri Kuthan authored on 22/09/2002 15:10:12
Showing 1 changed files
... ...
@@ -357,13 +357,13 @@ tryagain:
357 357
 	if ( (flags=fcntl(fifofd, F_GETFL, 0))<0) {
358 358
 		LOG(L_ERR, "ERROR: open_reply_pipe (%s): getfl failed: %s\n",
359 359
 			pipe_name, strerror(errno));
360
-		return 0;
360
+		goto error;
361 361
 	}
362 362
 	flags&=~O_NONBLOCK;
363 363
 	if (fcntl(fifofd, F_SETFL, flags)<0) {
364 364
 		LOG(L_ERR, "ERROR: open_reply_pipe (%s): setfl cntl failed: %s\n",
365 365
 			pipe_name, strerror(errno));
366
-		return 0;
366
+		goto error;
367 367
 	}
368 368
 
369 369
 	/* create an I/O stream */	
... ...
@@ -371,9 +371,12 @@ tryagain:
371 371
 	if (file_handle==NULL) {
372 372
 		LOG(L_ERR, "ERROR: open_reply_pipe: open error (%s): %s\n",
373 373
 			pipe_name, strerror(errno));
374
-		return 0;
374
+		goto error;
375 375
 	}
376 376
 	return file_handle;
377
+error:
378
+	close(fifofd);
379
+	return 0;
377 380
 }
378 381
 
379 382
 static void fifo_server(FILE *fifo_stream)