Browse code

additional ESPIPE handling intorduced

Jiri Kuthan authored on 27/08/2002 12:12:39
Showing 1 changed files
... ...
@@ -99,9 +99,21 @@ int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param)
99 99
 int read_line( char *b, int max, FILE *stream, int *read )
100 100
 {
101 101
 	int len;
102
+	int retry_cnt;
103
+
104
+	retry_cnt=0;
105
+
106
+retry:
102 107
 	if (fgets(b, max, stream)==NULL) {
103 108
 		LOG(L_ERR, "ERROR: fifo_server fgets failed: %s\n",
104 109
 			strerror(errno));
110
+		/* on Linux, fgets sometimes returns ESPIPE -- give
111
+		   it few more chances
112
+		*/
113
+		if (errno==ESPIPE) {
114
+			retry_cnt++;
115
+			if (retry_cnt<4) goto retry;
116
+		}
105 117
 		kill(0, SIGTERM);
106 118
 	}
107 119
 	/* if we did not read whole line, our buffer is too small