- * This is a modified read() to make SURE we get the number
- * of bytes we are told to, otherwise block.
- *
- * Modified to count errno (Sébastien Carpe <scarpe@atos-group.com>)
- *
-*/
-int aim_failsaferead(int fd, u_char *buf, int len)
-{
- int i = 0;
- int j = 0;
- int err_count=0;
-
- while ((i < len) && (!(i < 0)))
- {
- j = read(fd, &(buf[i]), len-i);
- if ( (j < 0) && (errno != EAGAIN))
- return -errno; /* fail */
- else if (j==0)
- {
- err_count++;
- if (err_count> MAX_READ_ERROR) {
- /*
- * Reached maximum number of allowed read errors.
- *
- * Lets suppose the connection is lost and errno didn't
- * know it.
- *
- */
- return (-1);
- }
- }
- else
- i += j; /* success, continue */
- }
- return i;
-}
-
-/*
- * Grab as many command sequences as we can off the socket, and enqueue
- * each command in the incoming event queue in a seperate struct.
+ * Grab a single command sequence off the socket, and enqueue
+ * it in the incoming event queue in a seperate struct.