]> Kevux Git Server - kevux-tools/commitdiff
Progress: Further work in TacocaT.
authorKevin Day <thekevinday@gmail.com>
Wed, 29 Nov 2023 04:23:41 +0000 (22:23 -0600)
committerKevin Day <thekevinday@gmail.com>
Wed, 29 Nov 2023 04:23:41 +0000 (22:23 -0600)
The socket id and id_data descriptors need to be initialized to -1 and not 0.
Make sure they are setup after allocation and after processing (or after disconnect).

Provide more verbose error reporting that reports the particular block step the send fails on.
The receive is not yet updated to do the same but in the future it should be updated to do so.

sources/c/tacocat/main/common.c
sources/c/tacocat/main/common/define.h
sources/c/tacocat/main/common/string.c
sources/c/tacocat/main/common/string.h
sources/c/tacocat/main/process.c
sources/c/tacocat/main/send.c

index 23e059a2bbb1ce76e75e332a0565b6b47008fc7b..79de62dad90f2f57bf187cfb8052f9d9cbf3362b 100644 (file)
@@ -346,6 +346,8 @@ extern "C" {
           sets[i]->array[j].packet.payload.stop = 0;
           sets[i]->array[j].retry = 0;
           sets[i]->array[j].status = F_okay;
+          sets[i]->array[j].socket.id = -1;
+          sets[i]->array[j].socket.id_data = -1;
           sets[i]->array[j].write_state.conversion = f_conversion_data_base_10_c;
           sets[i]->array[j].write_state.cache = &sets[i]->array[j].cache;
 
index df048685f7b6744071dfc6f7125ccfd5880f0461..4f07a0ab776d89e525319f8df18c92d74998d1f9 100644 (file)
@@ -180,9 +180,9 @@ extern "C" {
       return; \
     }
 
-  #define macro_kt_send_process_handle_error_exit_1(main, method, network, status, name, flag) \
+  #define macro_kt_send_process_handle_error_exit_1(main, method, on, network, status, name, flag) \
     if (F_status_is_error(status)) { \
-      kt_tacocat_print_error_on(&main->program.error, macro_kt_tacocat_f(method), kt_tacocat_send_s, network, status, name); \
+      kt_tacocat_print_error_on(&main->program.error, macro_kt_tacocat_f(method), on, network, status, name); \
       \
       return F_done_not; \
     }
index 0872b2f196ee198c4977892149c1fb85a1873acf..acd2ec05d17f37e841a238d0c0f80307b321e5e5 100644 (file)
@@ -26,6 +26,14 @@ extern "C" {
   const f_string_static_t kt_tacocat_network_or_socket_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_network_or_socket_s, 0, KT_TACOCAT_network_or_socket_s_length);
   const f_string_static_t kt_tacocat_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_receive_s, 0, KT_TACOCAT_receive_s_length);
   const f_string_static_t kt_tacocat_send_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_s, 0, KT_TACOCAT_send_s_length);
+  const f_string_static_t kt_tacocat_send_build_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_build_s, 0, KT_TACOCAT_send_build_s_length);
+  const f_string_static_t kt_tacocat_send_combine_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_combine_s, 0, KT_TACOCAT_send_combine_s_length);
+  const f_string_static_t kt_tacocat_send_connect_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_connect_s, 0, KT_TACOCAT_send_connect_s_length);
+  const f_string_static_t kt_tacocat_send_done_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_done_s, 0, KT_TACOCAT_send_done_s_length);
+  const f_string_static_t kt_tacocat_send_file_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_file_s, 0, KT_TACOCAT_send_file_s_length);
+  const f_string_static_t kt_tacocat_send_header_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_header_s, 0, KT_TACOCAT_send_header_s_length);
+  const f_string_static_t kt_tacocat_send_payload_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_payload_s, 0, KT_TACOCAT_send_payload_s_length);
+  const f_string_static_t kt_tacocat_send_size_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_size_s, 0, KT_TACOCAT_send_size_s_length);
   const f_string_static_t kt_tacocat_socket_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_socket_s, 0, KT_TACOCAT_socket_s_length);
   const f_string_static_t kt_tacocat_tacocat_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_tacocat_s, 0, KT_TACOCAT_tacocat_s_length);
   const f_string_static_t kt_tacocat_two_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_two_s, 0, KT_TACOCAT_two_s_length);
index df04c1007c288411de9054dfad2bec53f9c1b31c..bcb0713fed1b1c610c54b93b937881a4d5d78628 100644 (file)
@@ -80,6 +80,14 @@ extern "C" {
   #define KT_TACOCAT_network_or_socket_s  "network / socket"
   #define KT_TACOCAT_receive_s            "receive"
   #define KT_TACOCAT_send_s               "send"
+  #define KT_TACOCAT_send_build_s         "send build"
+  #define KT_TACOCAT_send_combine_s       "send combine"
+  #define KT_TACOCAT_send_connect_s       "send connect"
+  #define KT_TACOCAT_send_done_s          "send done"
+  #define KT_TACOCAT_send_file_s          "send file"
+  #define KT_TACOCAT_send_header_s        "send header"
+  #define KT_TACOCAT_send_payload_s       "send payload"
+  #define KT_TACOCAT_send_size_s          "send size"
   #define KT_TACOCAT_socket_s             "socket"
   #define KT_TACOCAT_tacocat_s            "tacocat"
   #define KT_TACOCAT_two_s                "two"
@@ -92,6 +100,14 @@ extern "C" {
   #define KT_TACOCAT_network_or_socket_s_length  16
   #define KT_TACOCAT_receive_s_length            7
   #define KT_TACOCAT_send_s_length               4
+  #define KT_TACOCAT_send_build_s_length         19
+  #define KT_TACOCAT_send_combine_s_length       12
+  #define KT_TACOCAT_send_connect_s_length       12
+  #define KT_TACOCAT_send_done_s_length          9
+  #define KT_TACOCAT_send_file_s_length          9
+  #define KT_TACOCAT_send_header_s_length        11
+  #define KT_TACOCAT_send_payload_s_length       12
+  #define KT_TACOCAT_send_size_s_length          9
   #define KT_TACOCAT_socket_s_length             6
   #define KT_TACOCAT_tacocat_s_length            7
   #define KT_TACOCAT_two_s_length                3
@@ -104,6 +120,14 @@ extern "C" {
   extern const f_string_static_t kt_tacocat_network_or_socket_s;
   extern const f_string_static_t kt_tacocat_receive_s;
   extern const f_string_static_t kt_tacocat_send_s;
+  extern const f_string_static_t kt_tacocat_send_build_s;
+  extern const f_string_static_t kt_tacocat_send_combine_s;
+  extern const f_string_static_t kt_tacocat_send_connect_s;
+  extern const f_string_static_t kt_tacocat_send_done_s;
+  extern const f_string_static_t kt_tacocat_send_file_s;
+  extern const f_string_static_t kt_tacocat_send_header_s;
+  extern const f_string_static_t kt_tacocat_send_payload_s;
+  extern const f_string_static_t kt_tacocat_send_size_s;
   extern const f_string_static_t kt_tacocat_socket_s;
   extern const f_string_static_t kt_tacocat_tacocat_s;
   extern const f_string_static_t kt_tacocat_two_s;
index 54acfb2bf6d704bed2505986c4f53bf8c4e25b81..72a0fccc29e3afce5abede2110694e9e99b9f497 100644 (file)
@@ -239,6 +239,9 @@ extern "C" {
         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;
+
       // Make the socket re-usable.
       {
         value_socket = 1;
@@ -349,6 +352,9 @@ extern "C" {
         if (F_status_is_error(status)) {
           f_socket_disconnect(&sets->array[i].socket, f_socket_close_read_write_e);
         }
+
+        sets->array[i].socket.id = -1;
+        sets->array[i].socket.id_data = -1;
       } // for
     }
 
index e082d5ca488c3278cc8f53b3b18685eb59e63903..ca1be97711339f99c9e02b4ad326515af190c34b 100644 (file)
@@ -76,8 +76,6 @@ extern "C" {
 
     if (!main || !set) return F_status_set_error(F_parameter);
 
-    // @todo this needs a max retries for sending without error, possibly resetting depending on the part (flag).
-
     if (!set->flag) {
       set->abstruses.used = 0;
       set->buffer.used = 0;
@@ -101,7 +99,7 @@ extern "C" {
       }
 
       if (F_status_is_error(set->status)) {
-        macro_kt_send_process_handle_error_exit_1(main, f_memory_array_increase_by, set->network, set->status, set->name, set->flag);
+        macro_kt_send_process_handle_error_exit_1(main, f_memory_array_increase_by, kt_tacocat_send_s, set->network, set->status, set->name, set->flag);
       }
 
       // Index 0 is the status.
@@ -151,6 +149,8 @@ extern "C" {
 
       // 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);
+      set->socket.id = -1;
+      set->socket.id_data = -1;
 
       kt_tacocat_print_error_on_max_retries(&main->program.error, kt_tacocat_send_s, set->network, set->name);
 
@@ -165,7 +165,7 @@ extern "C" {
       set->status = f_file_size_by_id(set->file, &total);
 
       if (F_status_is_error(set->status)) {
-        kt_tacocat_print_error_on_file_receive(&main->program.error, macro_kt_tacocat_f(f_file_size_by_id), kt_tacocat_send_s, set->network, set->status, set->name, f_file_operation_open_s);
+        kt_tacocat_print_error_on_file_receive(&main->program.error, macro_kt_tacocat_f(f_file_size_by_id), kt_tacocat_send_size_s, set->network, set->status, set->name, f_file_operation_open_s);
 
         return F_done_not;
       }
@@ -173,7 +173,7 @@ extern "C" {
       if ((f_number_unsigned_t) total > F_number_t_size_unsigned_d) {
         set->status = F_status_set_error(F_too_large);
 
-        kt_tacocat_print_error_on_file_too_large(&main->program.error, set->name, kt_tacocat_send_s, set->network, F_number_t_size_unsigned_d, set->abstruses.array[4].value.is.a_unsigned);
+        kt_tacocat_print_error_on_file_too_large(&main->program.error, set->name, kt_tacocat_send_size_s, set->network, F_number_t_size_unsigned_d, set->abstruses.array[4].value.is.a_unsigned);
 
         return F_done_not;
       }
@@ -208,7 +208,7 @@ extern "C" {
       }
 
       if (F_status_is_error(set->status)) {
-        macro_kt_send_process_handle_error_exit_1(main, f_file_read_block, set->network, set->status, set->name, set->flag);
+        macro_kt_send_process_handle_error_exit_1(main, f_file_read_block, kt_tacocat_send_file_s, set->network, set->status, set->name, set->flag);
       }
 
       set->abstruses.array[2].value.is.a_unsigned = set->buffer.used - f_fss_payload_object_payload_s.used - f_fss_payload_object_end_s.used;
@@ -224,7 +224,7 @@ extern "C" {
         state_local.data = &set->write_state;
 
         fl_fss_payload_header_map(set->abstruses, &set->headers, &state_local);
-        macro_kt_send_process_handle_error_exit_1(main, fl_fss_payload_header_map, set->network, state_local.status, set->name, set->flag);
+        macro_kt_send_process_handle_error_exit_1(main, fl_fss_payload_header_map, kt_tacocat_send_build_s, set->network, state_local.status, set->name, set->flag);
 
         set->flag = kt_tacocat_socket_flag_send_combine_e;
       }
@@ -274,7 +274,7 @@ extern "C" {
       }
 
       if (F_status_is_error_not(set->status)) {
-        macro_kt_send_process_handle_error_exit_1(main, f_string_dynamic_append, set->network, set->status, set->name, set->flag);
+        macro_kt_send_process_handle_error_exit_1(main, f_string_dynamic_append, kt_tacocat_send_combine_s, set->network, set->status, set->name, set->flag);
       }
 
       set->header.string[set->header.used] = 0;
@@ -283,8 +283,9 @@ extern "C" {
 
     if (set->flag == kt_tacocat_socket_flag_send_connect_e) {
       set->status = f_socket_connect(set->socket);
-      macro_kt_send_process_handle_error_exit_1(main, f_socket_connect, set->network, set->status, set->name, set->flag);
+      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);
 
+      set->socket.id_data = set->socket.id;
       set->flag = kt_tacocat_socket_flag_send_header_e;
     }
 
@@ -292,7 +293,7 @@ extern "C" {
       size_t written = 0;
 
       set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->header.string + set->size_done), &written);
-      macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, set->network, set->status, set->name, set->flag);
+      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;
 
@@ -312,7 +313,7 @@ extern "C" {
       size_t written = 0;
 
       set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->buffer.string + set->size_done), &written);
-      macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, set->network, set->status, set->name, set->flag);
+      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;
 
@@ -335,15 +336,17 @@ extern "C" {
       set->status = f_file_close(&set->file);
 
       if (F_status_is_error(set->status)) {
-        kt_tacocat_print_warning_on_file(&main->program.warning, macro_kt_tacocat_f(f_file_close), kt_tacocat_send_s, set->network, set->status, set->name, f_file_operation_close_s);
+        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);
 
       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_s, set->network, set->status, set->name, f_file_operation_close_s);
+        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);
       }
 
+      set->socket.id = -1;
+      set->socket.id_data = -1;
       set->status = F_okay;
 
       return F_done;