| 249 | } |
| 250 | |
| 251 | static void do_setup_rx(int domain, int type, int protocol) |
| 252 | { |
| 253 | struct sockaddr_storage addr = {}; |
| 254 | struct thread_data *td; |
| 255 | int listen_fd, fd; |
| 256 | unsigned int i; |
| 257 | |
| 258 | fd = socket(domain, type, protocol); |
| 259 | if (fd == -1) |
| 260 | t_error(1, errno, "socket r"); |
| 261 | |
| 262 | do_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, 1); |
| 263 | |
| 264 | setup_sockaddr(cfg_family, str_addr, &addr); |
| 265 | |
| 266 | if (bind(fd, (void *)&addr, cfg_alen)) |
| 267 | t_error(1, errno, "bind"); |
| 268 | |
| 269 | if (type != SOCK_STREAM) { |
| 270 | if (cfg_nr_threads != 1) |
| 271 | t_error(1, 0, "udp rx cant multithread"); |
| 272 | threads[0].fd = fd; |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | listen_fd = fd; |
| 277 | if (listen(listen_fd, cfg_nr_threads)) |
| 278 | t_error(1, errno, "listen"); |
| 279 | |
| 280 | for (i = 0; i < cfg_nr_threads; i++) { |
| 281 | td = &threads[i]; |
| 282 | |
| 283 | fd = accept(listen_fd, NULL, NULL); |
| 284 | if (fd == -1) |
| 285 | t_error(1, errno, "accept"); |
| 286 | td->fd = fd; |
| 287 | } |
| 288 | |
| 289 | if (close(listen_fd)) |
| 290 | t_error(1, errno, "close listen sock"); |
| 291 | } |
| 292 | |
| 293 | static void *do_rx(void *arg) |
| 294 | { |
no test coverage detected