On 12/17/2010 05:41 PM, Sebastian Dransfeld wrote:
On 12/17/2010 09:06 AM, Sebastian Dransfeld wrote:
On 12/17/2010 05:30 AM, Mike McCormack wrote:
On 12/17/2010 05:41 AM, Sebastian Dransfeld wrote:

num = read(svr->fd, buf, sizeof(buf));
- if ((num> 0) || (errno == EAGAIN))
+ if ((num>= 0) || (errno == EAGAIN))
lost_server = EINA_FALSE;

Sure this is right? a ret 0 an errno != EAGAIN is probably a lost
server.

0 is a successful return, so errno is not set in that case.

The above fix looks correct to me.

Depends on how the main loop works. We had this discussion a while ago,
and the result was:

http://trac.enlightenment.org/e/changeset/54209/trunk/ecore/src/lib/ecore_con/ecore_con.c



And:

http://stackoverflow.com/questions/2416944/can-read-function-on-a-connected-socket-return-zero-bytes


So 0 is _not_ a valid return value on a tcp socket.
read doesn't touch errno if it returns 0, as the attached test show.

If you think it behaves differently for a socket somehow, please extend the 
test and show me.

thanks,

Mike
/*
 * compile:
 * gcc -o read_zero -Wall read_zero.c
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	int fd;
	char buf[1];
	char name[20] = "/tmp/.zerotestXXXXXX";
	int r;

	fd = mkstemp(name);
	if (fd < 0)
	{
		fprintf(stderr, "failed to create file");
		return 1;
	}

	printf("filename = %s\n", name);

	errno = EIO;
	r = read(fd, buf, sizeof buf);
	if (r)
	{
		printf("r = %d\n", r);
	}
	else if (errno == EIO)
	{
		printf("errno untouched\n");
	}

	close(fd);

	return 0;
}
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to