]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Sun, 27 Mar 2022 17:48:33 +0000 (10:48 -0700)
committeralex <[email protected]>
Sun, 27 Mar 2022 17:48:33 +0000 (10:48 -0700)
src/net/send.c
test/unit/Makefile.am
test/unit/net.tests.c

index f73c23c7a6c5c8ae0d5be4e55f38f8c63cb6a323..e206987f3d576866ee0d86214584d126dbe91faf 100644 (file)
@@ -4,6 +4,13 @@ int net_send(int sock, struct peer *info, void *p, size_t size) {
        ssize_t i;
 
        i = send(sock,p,size,0);
+       if(-1==i) {
+               if(!((errno==EAGAIN)||(errno==EWOULDBLOCK))) {
+                       perror("send");
+                       return -1;
+               }
+       }
+
        if(i<size) { goto cache; }
 
        return 1;
index 2605ba15c2bf4fd84debf45dac67b4e5f332ed24..ebc7039f2ed40e504cb034be7f78fe678a1f1da7 100644 (file)
@@ -119,8 +119,10 @@ meta_tests_CPPFLAGS = $(AM_CPPFLAGS) \
 net_tests_SOURCES = \
        $(common_SOURCES) \
        net.tests.c \
+       $(top_srcdir)/src/net/cache.c \
        $(top_srcdir)/src/net/send.c \
-       $(top_srcdir)/src/net/wait.c
+       $(top_srcdir)/src/net/wait.c \
+       $(top_srcdir)/src/peer/init.c
        
 opt_tests_SOURCES = \
        $(common_SOURCES) \
index 55399d0860fad3dcf02249ab8e5c091ffb6bdf39..934e50551c45998369540c5f26675dda9e09f0df 100644 (file)
@@ -7,10 +7,14 @@ static int setup_socket();
 static void net_send_basic_test();
 static void net_wait_basic_test();
 
+static int read_socket;
+static int write_socket;
+
 int main() {
        setup_env();
 
        net_send_basic_test();
+       net_wait_basic_test();
 
        clean_env();
 
@@ -88,6 +92,11 @@ static void net_wait_basic_test() {
        close(sock);
 }
 
-static int setup_socket() {
-       return -1;
+static int setup_sockets() {
+       int sock = socket(AF_UNIX,SOCK_STREAM,0);
+       assert(sock!=-1);
+
+       assert(0==bind(sock,
+
+       return sock;
 }