summaryrefslogtreecommitdiff
path: root/networking/isrv_identd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 12:31:26 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 12:31:26 +0000
commitc14c95ec89b50c936c72c431f867fccf71a324eb (patch)
treea7be7640d0e2d02c2bb4db08a0a28015934ccfef /networking/isrv_identd.c
parent19250813a83cb4e1691810d1887658e60e2942d8 (diff)
downloadbusybox-w32-c14c95ec89b50c936c72c431f867fccf71a324eb.tar.gz
busybox-w32-c14c95ec89b50c936c72c431f867fccf71a324eb.tar.bz2
busybox-w32-c14c95ec89b50c936c72c431f867fccf71a324eb.zip
fakeidentd: avoid extra fcntl calls
Diffstat (limited to 'networking/isrv_identd.c')
-rw-r--r--networking/isrv_identd.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index 30f9a7a26..389103920 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -41,11 +41,13 @@ static int do_rd(int fd, void **paramp)
41{ 41{
42 identd_buf_t *buf = *paramp; 42 identd_buf_t *buf = *paramp;
43 char *cur, *p; 43 char *cur, *p;
44 int retval = 0; /* session is ok (so far) */
44 int sz; 45 int sz;
45 46
46 cur = buf->buf + buf->pos; 47 cur = buf->buf + buf->pos;
47 48
48 fcntl(fd, F_SETFL, buf->fd_flag); 49 if (buf->fd_flag & O_NONBLOCK)
50 fcntl(fd, F_SETFL, buf->fd_flag);
49 sz = safe_read(fd, cur, sizeof(buf->buf) - buf->pos); 51 sz = safe_read(fd, cur, sizeof(buf->buf) - buf->pos);
50 52
51 if (sz < 0) { 53 if (sz < 0) {
@@ -59,18 +61,18 @@ static int do_rd(int fd, void **paramp)
59 p = strpbrk(cur, "\r\n"); 61 p = strpbrk(cur, "\r\n");
60 if (p) 62 if (p)
61 *p = '\0'; 63 *p = '\0';
62 if (p || !sz || buf->pos == sizeof(buf->buf)) { 64 if (!p && sz && buf->pos <= sizeof(buf->buf))
63 /* fd is still in nonblocking mode - we never block here */ 65 goto ok;
64 fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser); 66 /* Terminate session. If we are in server mode, then
65 goto term; 67 * fd is still in nonblocking mode - we never block here */
66 } 68 fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
67 ok:
68 fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
69 return 0;
70 term: 69 term:
71 fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
72 free(buf); 70 free(buf);
73 return 1; 71 retval = 1; /* terminate */
72 ok:
73 if (buf->fd_flag & O_NONBLOCK)
74 fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
75 return retval;
74} 76}
75 77
76static int do_timeout(void **paramp) 78static int do_timeout(void **paramp)