diff -Naur motion-20060711-051001_orig/webcam.c motion-20060711-051001/webcam.c --- motion-20060711-051001_orig/webcam.c 2006-07-11 05:10:02.000000000 +0200 +++ motion-20060711-051001/webcam.c 2006-07-11 17:17:03.000000000 +0200 @@ -105,6 +105,12 @@ int workdone = 0; /* flag set any time data is successfully written */ + struct timeval curtimeval; + unsigned long int curtime; + + gettimeofday(&curtimeval, NULL); + curtime=curtimeval.tv_usec+1000000L*curtimeval.tv_sec; + client = list->next; while (client) { @@ -141,6 +147,11 @@ } else written = 0; + /* If we could not write for 10 seconds set errno to ETIMEDOUT */ + if (written < 0 && errno==EAGAIN && curtime - client->last >= 10000000L) { + motion_log(LOG_ERR, 1, "timeout"); + errno = ETIMEDOUT; + } /* If we have written the entire buffer to the socket, * or if there was some error (other than EAGAIN, which * means the system couldn't take it), this request is