Rename socket_connected to socket_ready, since we use it before accept()
This commit is contained in:
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
|
|
||||||
void flow_socket_connected(int fd, struct flow *flow) {
|
void flow_socket_ready(int fd, struct flow *flow) {
|
||||||
socket_connected(fd);
|
socket_ready(fd);
|
||||||
if (flow->socket_connected) {
|
if (flow->socket_ready) {
|
||||||
flow->socket_connected(fd);
|
flow->socket_ready(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ struct peer;
|
|||||||
|
|
||||||
struct flow {
|
struct flow {
|
||||||
const char *name;
|
const char *name;
|
||||||
void (*socket_connected)(int);
|
void (*socket_ready)(int);
|
||||||
void (*new)(int, void *, struct peer *);
|
void (*new)(int, void *, struct peer *);
|
||||||
void (*get_hello)(struct buf **, void *);
|
void (*get_hello)(struct buf **, void *);
|
||||||
uint32_t *ref_count;
|
uint32_t *ref_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
void flow_socket_connected(int, struct flow *);
|
void flow_socket_ready(int, struct flow *);
|
||||||
bool flow_hello(int, struct flow *, void *);
|
bool flow_hello(int, struct flow *, void *);
|
||||||
bool flow_new(int, struct flow *, void *);
|
bool flow_new(int, struct flow *, void *);
|
||||||
void flow_ref_inc(struct flow *);
|
void flow_ref_inc(struct flow *);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ static void incoming_listen(struct peer *peer) {
|
|||||||
|
|
||||||
socket_pre_listen(incoming->peer.fd);
|
socket_pre_listen(incoming->peer.fd);
|
||||||
// Options are inherited through accept()
|
// Options are inherited through accept()
|
||||||
flow_socket_connected(incoming->peer.fd, incoming->flow);
|
flow_socket_ready(incoming->peer.fd, incoming->flow);
|
||||||
|
|
||||||
assert(listen(incoming->peer.fd, 255) == 0);
|
assert(listen(incoming->peer.fd, 255) == 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ static void outgoing_connect_result(struct outgoing *outgoing, int result) {
|
|||||||
case 0:
|
case 0:
|
||||||
fprintf(stderr, "O %s: Connected to %s/%s\n", outgoing->id, hbuf, sbuf);
|
fprintf(stderr, "O %s: Connected to %s/%s\n", outgoing->id, hbuf, sbuf);
|
||||||
freeaddrinfo(outgoing->addrs);
|
freeaddrinfo(outgoing->addrs);
|
||||||
flow_socket_connected(outgoing->peer.fd, outgoing->flow);
|
flow_socket_ready(outgoing->peer.fd, outgoing->flow);
|
||||||
outgoing->attempt = 0;
|
outgoing->attempt = 0;
|
||||||
int fd = outgoing->peer.fd;
|
int fd = outgoing->peer.fd;
|
||||||
outgoing->peer.fd = -1;
|
outgoing->peer.fd = -1;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static void send_get_hello(struct buf **, void *);
|
|||||||
|
|
||||||
static struct flow _send_flow = {
|
static struct flow _send_flow = {
|
||||||
.name = "send",
|
.name = "send",
|
||||||
.socket_connected = socket_connected_send,
|
.socket_ready = socket_ready_send,
|
||||||
.new = send_new,
|
.new = send_new,
|
||||||
.get_hello = send_get_hello,
|
.get_hello = send_get_hello,
|
||||||
.ref_count = &peer_count_out,
|
.ref_count = &peer_count_out,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void socket_pre_listen(int fd) {
|
|||||||
assert(!setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)));
|
assert(!setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_connected(int fd) {
|
void socket_ready(int fd) {
|
||||||
// Called by transport code; safe to assume that fd is a socket
|
// Called by transport code; safe to assume that fd is a socket
|
||||||
int optval = 1;
|
int optval = 1;
|
||||||
assert(!setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)));
|
assert(!setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)));
|
||||||
@@ -31,7 +31,7 @@ void socket_connected(int fd) {
|
|||||||
assert(!setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &optval, sizeof(optval)));
|
assert(!setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &optval, sizeof(optval)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_connected_send(int fd) {
|
void socket_ready_send(int fd) {
|
||||||
int optval = 128; // Lowest value that the kernel will accept
|
int optval = 128; // Lowest value that the kernel will accept
|
||||||
int res = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &optval, sizeof(optval));
|
int res = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &optval, sizeof(optval));
|
||||||
if (res == -1 && errno == ENOTSOCK) {
|
if (res == -1 && errno == ENOTSOCK) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
void socket_pre_bind(int);
|
void socket_pre_bind(int);
|
||||||
void socket_pre_listen(int);
|
void socket_pre_listen(int);
|
||||||
void socket_connected(int);
|
void socket_ready(int);
|
||||||
void socket_connected_send(int);
|
void socket_ready_send(int);
|
||||||
void socket_send(int);
|
void socket_send(int);
|
||||||
void socket_receive(int);
|
void socket_receive(int);
|
||||||
|
|||||||
Reference in New Issue
Block a user