]> Kevux Git Server - kevux-tools/commitdiff
Progress: Further work in TacocaT.
authorKevin Day <thekevinday@gmail.com>
Mon, 11 Dec 2023 06:32:38 +0000 (00:32 -0600)
committerKevin Day <thekevinday@gmail.com>
Mon, 11 Dec 2023 06:32:38 +0000 (00:32 -0600)
The F_pipe is being returned on socket write calls because the socket.address.inet4.sin_family (and probably the socket.address.inet4.sin_family) is not being set.

The kt_tacocat_socket_flag_send_connect_e is not needed and is now removed.

Use f_socket_close_fast_e in f_socket_disconnect().

Pass f_socket_flag_signal_not_e as a flag to f_socket_write_stream() so that a signal is not received if f_socket_write_stream() returns F_pipe.

sources/c/tacocat/main/common.c
sources/c/tacocat/main/common/enumeration.h
sources/c/tacocat/main/process.c
sources/c/tacocat/main/send.c

index 3cfbc50571c85d3de2c2feb58345603210d66f7d..7dbc1502deac5ab6d699f26d3993ff299303c410 100644 (file)
@@ -521,11 +521,13 @@ extern "C" {
 
               if (host.h_addrtype == f_socket_address_family_inet4_e) {
                 sets[i]->array[j].socket.domain = f_socket_protocol_family_inet4_e;
+                sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet4_e;
                 sets[i]->array[j].socket.address.inet4.sin_port = htons((in_port_t) port);
                 sets[i]->array[j].socket.address.inet4.sin_addr.s_addr = family.address.v4.s_addr;
               }
               else if (host.h_addrtype == f_socket_address_family_inet6_e) {
                 sets[i]->array[j].socket.domain = f_socket_protocol_family_inet6_e;
+                sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet6_e;
                 sets[i]->array[j].socket.address.inet6.sin6_port = htons((in_port_t) port);
                 sets[i]->array[j].socket.address.inet6.sin6_addr = family.address.v6;
               }
index 808e2ed2e713762e34aae8fc5c11d43352b76fd3..93ba773978f9f688985e4cd86374fe92192d144d 100644 (file)
@@ -151,7 +151,6 @@ extern "C" {
  *   - file:    Buffer the file.
  *   - build:   Build the header information.
  *   - combine: Combine the built header information into a single buffer.
- *   - connect: Connect to the remote address.
  *   - header:  Send the header information.
  *   - payload: Send the payload information.
  *   - done:    The entire Packet is sent.
@@ -163,10 +162,9 @@ extern "C" {
     kt_tacocat_socket_flag_send_file_e    = 0x2,
     kt_tacocat_socket_flag_send_build_e   = 0x4,
     kt_tacocat_socket_flag_send_combine_e = 0x8,
-    kt_tacocat_socket_flag_send_connect_e = 0x10,
-    kt_tacocat_socket_flag_send_header_e  = 0x20,
-    kt_tacocat_socket_flag_send_payload_e = 0x40,
-    kt_tacocat_socket_flag_send_done_e    = 0x80,
+    kt_tacocat_socket_flag_send_header_e  = 0x10,
+    kt_tacocat_socket_flag_send_payload_e = 0x20,
+    kt_tacocat_socket_flag_send_done_e    = 0x40,
   }; // enum
 #endif // _di_kt_tacocat_socket_flag_send_e_
 
index 49945a300a9b2ee513f8225fc8af07cbf2a67360..61017911556700fd2e7fe428bbc54dd4984e99fc 100644 (file)
@@ -227,31 +227,14 @@ extern "C" {
         continue;
       }
 
-      // Make the socket re-usable.
-      {
-        value_socket = 1;
-
-        main->setting.send.array[i].status = f_socket_option_set(&main->setting.send.array[i].socket, SOL_SOCKET, f_socket_option_address_reuse_e | f_socket_option_port_reuse_e, &value_socket, sizeof(int));
-
-        if (F_status_is_error(main->setting.send.array[i].status)) {
-          main->setting.status_send = main->setting.send.array[i].status;
-
-          kt_tacocat_print_error_status(&main->program.error, macro_kt_tacocat_f(f_socket_option_set), main->setting.status_send);
-
-          continue;
-        }
-      }
+      // The id_data socket ID is the same when sending (writing) to the socket.
+      main->setting.send.array[i].socket.id_data = main->setting.send.array[i].socket.id;
 
       for (main->setting.send.array[i].retry = 0; main->setting.send.array[i].retry < kt_tacocat_startup_retry_max_d; ++main->setting.send.array[i].retry) {
 
         if (main->setting.send.array[i].socket.domain == f_socket_protocol_family_inet4_e || main->setting.send.array[i].socket.domain == f_socket_protocol_family_inet6_e || main->setting.send.array[i].socket.domain == f_socket_protocol_family_local_e) {
           main->setting.send.array[i].status = f_socket_connect(&main->setting.send.array[i].socket);
 
-          // The id_data socket ID is the same when sending (writing) to the socket.
-          if (F_status_is_error_not(main->setting.send.array[i].status)) {
-            main->setting.send.array[i].socket.id_data = main->setting.send.array[i].socket.id;
-          }
-
           // Treat invalid file descriptor as an error as the descriptor should be valid at this point in time.
           if (main->setting.send.array[i].status == F_file_descriptor) {
             main->setting.send.array[i].status = F_status_set_error(F_file_descriptor);
@@ -311,6 +294,7 @@ extern "C" {
         continue;
       }
 
+      // @fixme are send_polls even used yet? This should be used to listen for and catch a response from the receive end after sending.
       if (main->setting.send.array[i].socket.id == -1) {
         main->setting.send_polls.array[i].fd = -1;
         main->setting.send_polls.array[i].events = 0;
@@ -343,11 +327,7 @@ extern "C" {
         f_file_close(&sets->array[i].file);
         f_file_close_id(&sets->array[i].socket.id_data);
 
-        status = f_socket_disconnect(&sets->array[i].socket, main->program.signal_received ? f_socket_close_fast_e : f_socket_close_read_write_e);
-
-        if (F_status_is_error(status)) {
-          f_socket_disconnect(&sets->array[i].socket, f_socket_close_read_write_e);
-        }
+        f_socket_disconnect(&sets->array[i].socket, f_socket_close_fast_e);
 
         sets->array[i].socket.id = -1;
         sets->array[i].socket.id_data = -1;
index 4a7ee2c8913bd120ae4e78816d066b2e253e9fcd..c468e8efe7a1c3f2fd7c3d9d455ce3ace00fdca1 100644 (file)
@@ -145,7 +145,7 @@ extern "C" {
 
     if (set->retry >= kt_tacocat_startup_retry_max_d) {
       f_file_close(&set->file);
-      f_socket_disconnect(&set->socket, f_socket_close_write_e);
+      f_socket_disconnect(&set->socket, f_socket_close_fast_e);
 
       // Keep error bit but set state to done to designate that nothing else is to be done.
       set->status = F_status_set_error(F_done);
@@ -278,19 +278,6 @@ extern "C" {
       }
 
       set->header.string[set->header.used] = 0;
-      set->flag = kt_tacocat_socket_flag_send_connect_e;
-    }
-
-    if (set->flag == kt_tacocat_socket_flag_send_connect_e) {
-      if (set->socket.id == -1) {
-        set->status = f_socket_connect(&set->socket);
-        macro_kt_send_process_handle_error_exit_1(main, f_socket_connect, kt_tacocat_send_connect_s, set->network, set->status, set->name, set->flag);
-      }
-
-      if (set->socket.id_data == -1) {
-        set->socket.id_data = set->socket.id;
-      }
-
       set->flag = kt_tacocat_socket_flag_send_header_e;
     }
 
@@ -299,7 +286,8 @@ extern "C" {
 
       set->socket.size_write = set->size_done + set->size_block > set->header.used ? set->header.used - set->size_done : set->size_block;
 
-      set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->header.string + set->size_done), &written);
+      set->status = f_socket_write_stream(&set->socket, f_socket_flag_signal_not_e, (void *) (set->header.string + set->size_done), &written);
+
       macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, kt_tacocat_send_header_s, set->network, set->status, set->name, set->flag);
 
       set->size_done += written;
@@ -321,7 +309,7 @@ extern "C" {
 
       set->socket.size_write = set->size_done + set->size_block > set->buffer.used ? set->buffer.used - set->size_done : set->size_block;
 
-      set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->buffer.string + set->size_done), &written);
+      set->status = f_socket_write_stream(&set->socket, f_socket_flag_signal_not_e, (void *) (set->buffer.string + set->size_done), &written);
       macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, kt_tacocat_send_payload_s, set->network, set->status, set->name, set->flag);
 
       set->size_done += written;
@@ -348,7 +336,7 @@ extern "C" {
         kt_tacocat_print_warning_on_file(&main->program.warning, macro_kt_tacocat_f(f_file_close), kt_tacocat_send_done_s, set->network, set->status, set->name, f_file_operation_close_s);
       }
 
-      set->status = f_socket_disconnect(&set->socket, f_socket_close_write_e);
+      set->status = f_socket_disconnect(&set->socket, f_socket_close_fast_e);
 
       if (F_status_is_error(set->status)) {
         kt_tacocat_print_warning_on_file(&main->program.warning, macro_kt_tacocat_f(f_socket_disconnect), kt_tacocat_send_done_s, set->network, set->status, set->name, f_file_operation_close_s);