svn commit: trunk/busybox/networking

vda at busybox.net vda at busybox.net
Sun Jan 14 12:31:28 UTC 2007


Author: vda
Date: 2007-01-14 04:31:26 -0800 (Sun, 14 Jan 2007)
New Revision: 17298

Log:
fakeidentd: avoid extra fcntl calls


Modified:
   trunk/busybox/networking/isrv_identd.c


Changeset:
Modified: trunk/busybox/networking/isrv_identd.c
===================================================================
--- trunk/busybox/networking/isrv_identd.c	2007-01-14 12:07:25 UTC (rev 17297)
+++ trunk/busybox/networking/isrv_identd.c	2007-01-14 12:31:26 UTC (rev 17298)
@@ -41,11 +41,13 @@
 {
 	identd_buf_t *buf = *paramp;
 	char *cur, *p;
+	int retval = 0; /* session is ok (so far) */
 	int sz;
 
 	cur = buf->buf + buf->pos;
 
-	fcntl(fd, F_SETFL, buf->fd_flag);
+	if (buf->fd_flag & O_NONBLOCK)
+		fcntl(fd, F_SETFL, buf->fd_flag);
 	sz = safe_read(fd, cur, sizeof(buf->buf) - buf->pos);
 
 	if (sz < 0) {
@@ -59,18 +61,18 @@
 	p = strpbrk(cur, "\r\n");
 	if (p)
 		*p = '\0';
-	if (p || !sz || buf->pos == sizeof(buf->buf)) {
-		/* fd is still in nonblocking mode - we never block here */
-		fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
-		goto term;
-	}
- ok:
-	fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
-	return 0;
+	if (!p && sz && buf->pos <= sizeof(buf->buf))
+		goto ok;
+	/* Terminate session. If we are in server mode, then
+	 * fd is still in nonblocking mode - we never block here */
+	fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
  term:
-	fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
 	free(buf);
-	return 1;
+	retval = 1; /* terminate */
+ ok:
+	if (buf->fd_flag & O_NONBLOCK)
+		fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
+	return retval;
 }
 
 static int do_timeout(void **paramp)




More information about the busybox-cvs mailing list