Lines Matching refs:fd
15 static void write_one(int fd)
17 if (write(fd, "1", 1) < 0)
21 static void read_one(int fd)
25 if (read(fd, &buf, 1) < 0)
59 static void test_istream_unix_server(int fd)
65 input = i_stream_create_unix(fd, 1024);
68 write_one(fd);
70 /* 2) fd was sent but we won't get it */
72 /* we still shouldn't have the fd */
78 write_one(fd);
80 /* 3) the previous fd should be lost now */
82 write_one(fd);
84 /* 4) we should get the fd now */
86 write_one(fd);
88 /* 5) the previous fd shouldn't be returned anymore */
91 write_one(fd);
93 /* 6) with i_stream_unix_unset_read_fd() we shouldn't get fd anymore */
96 write_one(fd);
102 write_one(fd);
109 write_one(fd);
112 i_close_fd(&fd);
115 static void test_istream_unix_client(int fd)
118 write_one(fd);
119 read_one(fd);
122 if (fd_send(fd, send_fd, "1", 1) < 0)
124 read_one(fd);
127 write_one(fd);
128 read_one(fd);
131 if (fd_send(fd, send_fd2, "1", 1) < 0)
133 read_one(fd);
136 write_one(fd);
137 read_one(fd);
140 if (fd_send(fd, send_fd, "1", 1) < 0)
142 read_one(fd);
145 if (fd_send(fd, send_fd, "1", 1) < 0)
147 if (fd_send(fd, send_fd2, "1", 1) < 0)
149 read_one(fd);
152 if (fd_send(fd, send_fd, "1", 1) < 0)
154 if (fd_send(fd, send_fd2, "1", 1) < 0)
156 read_one(fd);
158 i_close_fd(&fd);
163 int fd[2];
170 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0)
176 i_close_fd(&fd[0]);
177 test_istream_unix_client(fd[1]);
180 i_close_fd(&fd[1]);
181 test_istream_unix_server(fd[0]);