MCPcopy Create free account
hub / github.com/F-Stack/f-stack / conn_req_poll

Function conn_req_poll

dpdk/app/graph/conn.c:203–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203int
204conn_req_poll(struct conn *conn)
205{
206 struct sockaddr_in client_address;
207 socklen_t client_address_length;
208 struct epoll_event event;
209 int fd_client, rc;
210
211 /* Check input arguments */
212 if (conn == NULL)
213 return -1;
214
215 /* Server socket */
216 client_address_length = sizeof(client_address);
217 fd_client = accept4(conn->fd_server, (struct sockaddr *)&client_address,
218 &client_address_length, SOCK_NONBLOCK);
219 if (fd_client == -1) {
220 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
221 return 0;
222
223 return -1;
224 }
225
226 /* Client group */
227 event.events = EPOLLIN | EPOLLRDHUP | EPOLLHUP;
228 event.data.fd = fd_client;
229
230 rc = epoll_ctl(conn->fd_client_group, EPOLL_CTL_ADD, fd_client, &event);
231 if (rc == -1) {
232 close(fd_client);
233 goto exit;
234 }
235
236 /* Client */
237 rc = write(fd_client, conn->welcome, strlen(conn->welcome));
238 if (rc == -1) {
239 close(fd_client);
240 goto exit;
241 }
242
243 rc = write(fd_client, conn->prompt, strlen(conn->prompt));
244 if (rc == -1) {
245 close(fd_client);
246 goto exit;
247 }
248
249 rc = 0;
250
251exit:
252 return rc;
253}
254
255int
256conn_msg_poll(struct conn *conn)

Callers 1

mainFunction · 0.85

Calls 4

epoll_ctlFunction · 0.85
accept4Function · 0.50
closeFunction · 0.50
writeFunction · 0.50

Tested by

no test coverage detected