rem: int rsd = -1; if (hm->pipe(&rsd, &cli_sa, cli_sa_len, &ip, cli_port, src, &local_cli_sa)) { ONVERBOSE(syslog(LOG_DEBUG, "Could not connect to remote destination")); socket_close(csd); return;
add: sleeper *s = new sleeper(hm, &cli_sa, &ip, cli_port, src, &local_cli_sa, csd, fds, dest_fd, maxfd); if (s->pipe()) { if (fragile) s->queue(); else { ONVERBOSE(syslog(LOG_DEBUG, "Could not connect to remote destination")); socket_close(csd); delete s; }
context: void mother_socket(int sd, fd_set *fds, int dest_fd[], int *maxfd, vector<host_map*> *map_list, const struct ip_addr *src){  struct sockaddr_in cli_sa;  socklen_t cli_sa_len = sizeof(cli_sa);  /*   * Accept new client on "csd"   */  int csd = accept(sd, (struct sockaddr *) &cli_sa, &cli_sa_len);  if (csd < 0) {    syslog(LOG_ERR, "Can't accept TCP socket: %m");    return;  }	  int cli_port = ntohs(cli_sa.sin_port);  /*   * Get local address   */  struct sockaddr_in local_cli_sa;  socklen_t local_cli_sa_len = sizeof(local_cli_sa);  if (getsockname(sd, (struct sockaddr *) &local_cli_sa, &local_cli_sa_len)) {    syslog(LOG_ERR, "mother_socket(): Can't get local sockname: %m");    socket_close(csd);    return;  }  ONVERBOSE(syslog(LOG_DEBUG, "TCP connection from %s:%d", inet_ntoa(cli_sa.sin_addr), cli_port));    /*   * Check client address (ip, port).   */  struct ip_addr ip;  ip.addr = (char *) &(cli_sa.sin_addr.s_addr);  ip.len  = addr_len;  host_map *hm = tcp_match(map_list, &ip, cli_port);  if (!hm) {    ONVERBOSE(syslog(LOG_DEBUG, "Address miss"));    socket_close(csd);    return;  }  ONVERBOSE(syslog(LOG_DEBUG, "Address match"));  /*   * Connect to destination on "rsd"   */  int rsd = -1;  if (hm->pipe(&rsd, &cli_sa, cli_sa_len, &ip, cli_port, src, &local_cli_sa)) {    ONVERBOSE(syslog(LOG_DEBUG, "Could not connect to remote destination"));    socket_close(csd);    return;  }    if ((csd >= MAX_FD) || (rsd >= MAX_FD)) {    syslog(LOG_ERR, "Destination socket descriptors overflow");    socket_close(csd);    socket_close(rsd);    return;  }  /*   * Add pair of communicating sockets.   */  fdset(csd, fds, maxfd);  fdset(rsd, fds, maxfd);    /*   * Save peers so they can be remembered later.   */  dest_fd[csd] = rsd;  dest_fd[rsd] = csd;}