Document of c-modernization-kit (porter) 1.0.0
Loading...
Searching...
No Matches
potrConnectThread.h File Reference

TCP 接続管理スレッドの内部ヘッダー。 More...

#include "../potrContext.h"
Include dependency graph for potrConnectThread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int potr_connect_thread_start (struct PotrContext_ *ctx)
 TCP 接続管理スレッドを起動します。
void potr_connect_thread_stop (struct PotrContext_ *ctx)
 TCP 接続管理スレッドを停止します。

Detailed Description

TCP 接続管理スレッドの内部ヘッダー。

Author
c-modernization-kit sample team
Date
2026/03/23
Version
1.0.0

SENDER: TCP connect / 自動再接続ループを管理するスレッドです。
RECEIVER: TCP accept ループを管理するスレッドです。
接続確立後、送受信・ヘルスチェックスレッドを起動します。

Definition in file potrConnectThread.h.

Function Documentation

◆ potr_connect_thread_start()

int potr_connect_thread_start ( struct PotrContext_ * ctx)
extern

TCP 接続管理スレッドを起動します。

Parameters
[in,out]ctxセッションコンテキストへのポインタ。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

TCP 接続管理スレッドを起動します。

Parameters
[in,out]ctxセッションコンテキストへのポインタ。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

呼び出し前提:

  • SENDER: dst_addr_resolved[i] および dst_port が設定済みであること (n_path 分)。
  • RECEIVER: tcp_listen_sock[i] が listen 状態であること (n_path 分)。
  • tcp_state_mutex / tcp_state_cv / tcp_send_mutex[] が初期化済みであること。

Definition at line 1084 of file potrConnectThread.c.

References PotrContext_::connect_thread, connect_thread_func(), PotrContext_::connect_thread_running, PotrContext_::global, PotrGlobalConfig::max_payload, PotrContext_::n_path, PACKET_HEADER_SIZE, POTR_ERROR, POTR_LOG, POTR_ROLE_RECEIVER, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, PotrContext_::role, s_connect_args, PotrContext_::service, PotrServiceDef::service_id, PotrContext_::session_establish_mutex, PotrContext_::tcp_first_pkt_buf, and PotrContext_::tcp_first_pkt_len.

Referenced by potrOpenService().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ potr_connect_thread_stop()

void potr_connect_thread_stop ( struct PotrContext_ * ctx)
extern

TCP 接続管理スレッドを停止します。

Parameters
[in,out]ctxセッションコンテキストへのポインタ。
[in,out]ctxセッションコンテキストへのポインタ。
  1. connect_thread_running[i] フラグを全 path クリアして停止を通知する。
  2. tcp_state_cv をブロードキャストして reconnect sleep を中断する。
  3. tcp_listen_sock[i] (RECEIVER) を全 path クローズして accept ブロックを解除する。
  4. tcp_conn_fd[i] を全 path クローズして recv ループをブロック解除する。
  5. connect_thread[i] の終了を全 path 待機する。
  6. 送信スレッドを停止する (全 path join 後)。 依存スレッド (recv/health) のクリーンアップは各 connect_thread 内で行われる。

Definition at line 1183 of file potrConnectThread.c.

References PotrContext_::connect_thread, PotrContext_::connect_thread_running, PotrContext_::n_path, POTR_INVALID_SOCKET, POTR_LOG, POTR_ROLE_RECEIVER, potr_send_thread_stop(), POTR_TRACE_VERBOSE, PotrContext_::role, PotrContext_::service, PotrServiceDef::service_id, PotrContext_::session_establish_mutex, PotrContext_::tcp_conn_fd, PotrContext_::tcp_first_pkt_buf, PotrContext_::tcp_first_pkt_len, PotrContext_::tcp_listen_sock, PotrContext_::tcp_state_cv, and PotrContext_::tcp_state_mutex.

Referenced by potrCloseService().

Here is the call graph for this function:
Here is the caller graph for this function: