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