From: alex Date: Sat, 2 Apr 2022 00:53:50 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=c450091c21ae6627faa6dccab7b20a0ad4afa15b;p=seeder ... --- diff --git a/Makefile.am b/Makefile.am index e102240..230a388 100644 --- a/Makefile.am +++ b/Makefile.am @@ -69,6 +69,7 @@ seederd_SOURCES = \ src/peer/interest.c \ src/peer/keepalive.c \ src/peer/piece.c \ + src/peer/queue.c \ src/peer/reject.c \ src/peer/request.c \ src/pqueue.c \ diff --git a/inc/peer.h b/inc/peer.h index 5db463f..d853943 100644 --- a/inc/peer.h +++ b/inc/peer.h @@ -77,6 +77,7 @@ int peer_not_interested(struct peer*); int peer_not_interested_received(struct peer*,ssize_t); int peer_piece(struct peer*); int peer_piece_received(struct peer*,ssize_t); +int peer_queue_process(struct peer*); int peer_reject(struct peer*); int peer_reject_received(struct peer*,ssize_t); int peer_request(struct peer*); diff --git a/src/net/handler.c b/src/net/handler.c index 0802c4b..5221117 100644 --- a/src/net/handler.c +++ b/src/net/handler.c @@ -12,7 +12,7 @@ void net_handler(int epoll_fd, struct peer *info) { if(info->out!=NULL) { goto remaining; } if(!info->handshake) { goto handshake; } - + if((i = net_expected(info,&type))<0) { goto close; } switch(type) { @@ -63,20 +63,25 @@ void net_handler(int epoll_fd, struct peer *info) { goto close; } + if(NULL==info->out) { goto send; } + goto queue; -remaining: - if(send_remaining(info)<0) { goto close; } - goto queue; +close: + close(info->sock); + peer_free(info); + return; handshake: if(peer_handshake(info)<0) { goto close; } goto queue; queue: if(net_queue(epoll_fd,info)<0) { goto close; } return; -close: - close(info->sock); - peer_free(info); - return; +remaining: + if(send_remaining(info)<0) { goto close; } + goto queue; +send: + if(peer_queue_process(info)<0) { goto close; } + goto queue; } static int send_remaining(struct peer *info) { diff --git a/src/peer/queue.c b/src/peer/queue.c new file mode 100644 index 0000000..7ad4df4 --- /dev/null +++ b/src/peer/queue.c @@ -0,0 +1,6 @@ +#include + +int peer_queue_process(struct peer *info) { + /* split between hashes/piece responses */ + return -1; +}