]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Sat, 2 Apr 2022 00:53:50 +0000 (17:53 -0700)
committeralex <[email protected]>
Sat, 2 Apr 2022 00:53:50 +0000 (17:53 -0700)
Makefile.am
inc/peer.h
src/net/handler.c
src/peer/queue.c [new file with mode: 0644]

index e102240b540ed5aff18f7d6e65b902cd72815502..230a3887ffc797860d4885a68146b895ea9f54a5 100644 (file)
@@ -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 \
index 5db463f1247932a5e67e47bb2e2e3db0e0c686a9..d853943a5aa4976bba1f4147defe88471ea3972f 100644 (file)
@@ -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*);
index 0802c4b77ded6081d9cb4722dcd99ccfb1191820..5221117bb4d78befa6bb1178ce15880026928fad 100644 (file)
@@ -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 (file)
index 0000000..7ad4df4
--- /dev/null
@@ -0,0 +1,6 @@
+#include<peer.h>
+
+int peer_queue_process(struct peer *info) {
+       /* split between hashes/piece responses */
+       return -1;
+}