| 52 |
|
"Error during DNS lookup", "connect timeout", "Error during connect()", |
| 53 |
|
"Comm Error" }; |
| 54 |
|
|
| 55 |
– |
struct Callback *setup_socket_cb = NULL; |
| 56 |
– |
|
| 55 |
|
static void comm_connect_callback(fde_t *, int); |
| 56 |
|
static PF comm_connect_timeout; |
| 57 |
|
static void comm_connect_dns_callback(void *, const struct irc_ssaddr *, const char *); |
| 137 |
|
* |
| 138 |
|
* Set the socket non-blocking, and other wonderful bits. |
| 139 |
|
*/ |
| 140 |
< |
static void * |
| 141 |
< |
setup_socket(va_list args) |
| 140 |
> |
static void |
| 141 |
> |
setup_socket(int fd) |
| 142 |
|
{ |
| 145 |
– |
int fd = va_arg(args, int); |
| 143 |
|
int opt = 1; |
| 144 |
|
|
| 145 |
|
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)); |
| 150 |
|
#endif |
| 151 |
|
|
| 152 |
|
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); |
| 156 |
– |
|
| 157 |
– |
return NULL; |
| 158 |
– |
} |
| 159 |
– |
|
| 160 |
– |
/* |
| 161 |
– |
* init_comm() |
| 162 |
– |
* |
| 163 |
– |
* Initializes comm subsystem. |
| 164 |
– |
*/ |
| 165 |
– |
void |
| 166 |
– |
init_comm(void) |
| 167 |
– |
{ |
| 168 |
– |
setup_socket_cb = register_callback("setup_socket", setup_socket); |
| 169 |
– |
init_netio(); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
/* |
| 695 |
|
if (fd < 0) |
| 696 |
|
return -1; /* errno will be passed through, yay.. */ |
| 697 |
|
|
| 698 |
< |
execute_callback(setup_socket_cb, fd); |
| 698 |
> |
setup_socket(fd); |
| 699 |
|
|
| 700 |
|
/* update things in our fd tracking */ |
| 701 |
|
fd_open(F, fd, 1, note); |
| 736 |
|
pn->ss_len = addrlen; |
| 737 |
|
#endif |
| 738 |
|
|
| 739 |
< |
execute_callback(setup_socket_cb, newfd); |
| 739 |
> |
setup_socket(newfd); |
| 740 |
|
|
| 741 |
|
/* .. and return */ |
| 742 |
|
return newfd; |