|
Document of c-modernization-kit (porter) 1.0.0
|
ヘルスチェックスレッドモジュール。 More...
#include <string.h>#include <inttypes.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#include <time.h>#include <porter_const.h>#include <porter.h>#include "../protocol/packet.h"#include "../protocol/window.h"#include "../potrContext.h"#include "../potrPeerTable.h"#include "potrHealthThread.h"#include "../infra/potrLog.h"#include "../infra/crypto/crypto.h"Go to the source code of this file.
Data Structures | |
| struct | HealthArg |
Macros | |
| #define | POTR_MUTEX_LOCK_LOCAL(m) |
| #define | POTR_MUTEX_UNLOCK_LOCAL(m) |
Functions | |
| static void | health_sleep (struct PotrContext_ *ctx, int path_idx, uint32_t interval_ms) |
| static uint64_t | health_get_ms (void) |
| static void * | health_thread_func (void *arg) |
| static void * | tcp_health_thread_func (void *arg) |
| int | potr_health_thread_start (struct PotrContext_ *ctx) |
| 非 TCP ヘルスチェックスレッドを起動します。 | |
| int | potr_health_thread_stop (struct PotrContext_ *ctx) |
| 非 TCP ヘルスチェックスレッドを停止します。 | |
| int | potr_tcp_health_thread_start (struct PotrContext_ *ctx, int path_idx) |
| TCP ヘルスチェックスレッドを path ごとに起動します。 | |
| int | potr_tcp_health_thread_stop (struct PotrContext_ *ctx, int path_idx) |
| TCP ヘルスチェックスレッドを停止します。 | |
Variables | |
| static HealthArg | s_health_args [POTR_MAX_PATH] |
ヘルスチェックスレッドモジュール。
送信者側で動作する定周期 PING 送信スレッドです。
health_interval_ms 周期で PING パケットを送信します。
受信者側から送信者へのヘルスチェックは行いません (一方向ヘルスチェック)。
Definition in file potrHealthThread.c.
| #define POTR_MUTEX_LOCK_LOCAL | ( | m | ) |
Definition at line 46 of file potrHealthThread.c.
Referenced by health_thread_func(), and tcp_health_thread_func().
| #define POTR_MUTEX_UNLOCK_LOCAL | ( | m | ) |
Definition at line 47 of file potrHealthThread.c.
Referenced by health_thread_func(), and tcp_health_thread_func().
|
static |
Definition at line 65 of file potrHealthThread.c.
References PotrContext_::health_mutex, PotrContext_::health_running, and PotrContext_::health_wakeup.
Referenced by health_thread_func(), and tcp_health_thread_func().
|
static |
Definition at line 96 of file potrHealthThread.c.
Referenced by health_thread_func(), and tcp_health_thread_func().
|
static |
Definition at line 111 of file potrHealthThread.c.
References PotrPeerContext_::active, PotrContext_::dest_addr, PotrPeerContext_::dest_addr, PotrServiceDef::encrypt_enabled, PotrServiceDef::encrypt_key, PotrPacket::flags, PotrContext_::global, health_get_ms(), PotrGlobalConfig::health_interval_ms, PotrContext_::health_running, health_sleep(), PotrContext_::is_multi_peer, PotrContext_::last_send_ms, PotrContext_::max_peers, PotrContext_::n_path, PotrWindow::next_seq, packet_build_ping(), PACKET_HEADER_SIZE, packet_wire_size(), PotrPacket::payload_len, PotrPeerContext_::peer_id, PotrContext_::peers, PotrContext_::peers_mutex, POTR_CRYPTO_NONCE_SIZE, POTR_CRYPTO_TAG_SIZE, potr_encrypt(), POTR_FLAG_ENCRYPTED, POTR_LOG, POTR_MAX_PATH, POTR_MUTEX_LOCK_LOCAL, POTR_MUTEX_UNLOCK_LOCAL, POTR_SUCCESS, POTR_TRACE_VERBOSE, PotrContext_::send_window, PotrPeerContext_::send_window, PotrContext_::send_window_mutex, PotrPeerContext_::send_window_mutex, PotrPacket::seq_num, PotrContext_::service, PotrPacketSessionHdr::service_id, PotrServiceDef::service_id, PotrContext_::session_id, PotrPacket::session_id, PotrPacketSessionHdr::session_id, PotrPeerContext_::session_id, PotrContext_::session_tv_nsec, PotrPacketSessionHdr::session_tv_nsec, PotrPeerContext_::session_tv_nsec, PotrContext_::session_tv_sec, PotrPacketSessionHdr::session_tv_sec, PotrPeerContext_::session_tv_sec, and PotrContext_::sock.
Referenced by potr_health_thread_start().
|
static |
Definition at line 354 of file potrHealthThread.c.
References HealthArg::ctx, PotrServiceDef::encrypt_enabled, PotrServiceDef::encrypt_key, PotrPacket::flags, PotrContext_::global, health_get_ms(), PotrGlobalConfig::health_interval_ms, PotrContext_::health_running, health_sleep(), PotrGlobalConfig::health_timeout_ms, PotrWindow::next_seq, packet_build_ping(), PACKET_HEADER_SIZE, packet_wire_size(), HealthArg::path_idx, PotrPacket::payload_len, POTR_CRYPTO_NONCE_SIZE, POTR_CRYPTO_TAG_SIZE, potr_encrypt(), POTR_FLAG_ENCRYPTED, POTR_INVALID_SOCKET, POTR_LOG, POTR_MUTEX_LOCK_LOCAL, POTR_MUTEX_UNLOCK_LOCAL, POTR_SUCCESS, POTR_TRACE_VERBOSE, POTR_TRACE_WARNING, PotrContext_::send_window, PotrContext_::send_window_mutex, PotrPacket::seq_num, PotrContext_::service, PotrPacketSessionHdr::service_id, PotrServiceDef::service_id, PotrContext_::session_id, PotrPacket::session_id, PotrPacketSessionHdr::session_id, PotrContext_::session_tv_nsec, PotrPacketSessionHdr::session_tv_nsec, PotrContext_::session_tv_sec, PotrPacketSessionHdr::session_tv_sec, PotrContext_::tcp_active_paths, PotrContext_::tcp_conn_fd, PotrContext_::tcp_last_ping_recv_ms, and PotrContext_::tcp_send_mutex.
Referenced by potr_tcp_health_thread_start().
| int potr_health_thread_start | ( | struct PotrContext_ * | ctx | ) |
非 TCP ヘルスチェックスレッドを起動します。
| [in,out] | ctx | セッションコンテキストへのポインタ。 |
ctx->global.health_interval_ms が 0 の場合は起動しません (POTR_SUCCESS を返します)。
Definition at line 526 of file potrHealthThread.c.
References PotrContext_::global, PotrGlobalConfig::health_interval_ms, PotrContext_::health_mutex, PotrContext_::health_running, PotrContext_::health_thread, health_thread_func(), PotrContext_::health_wakeup, POTR_ERROR, POTR_LOG, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, PotrContext_::service, and PotrServiceDef::service_id.
Referenced by potrOpenService().
| int potr_health_thread_stop | ( | struct PotrContext_ * | ctx | ) |
非 TCP ヘルスチェックスレッドを停止します。
| [in,out] | ctx | セッションコンテキストへのポインタ。 |
Definition at line 584 of file potrHealthThread.c.
References PotrContext_::health_mutex, PotrContext_::health_running, PotrContext_::health_thread, PotrContext_::health_wakeup, POTR_ERROR, and POTR_SUCCESS.
Referenced by potrCloseService(), and potrOpenService().
| int potr_tcp_health_thread_start | ( | struct PotrContext_ * | ctx, |
| int | path_idx ) |
TCP ヘルスチェックスレッドを path ごとに起動します。
| [in,out] | ctx | セッションコンテキストへのポインタ。 |
| [in] | path_idx | パスインデックス (0 ~ n_path-1)。 |
ctx->global.health_interval_ms が 0 の場合は起動しません (POTR_SUCCESS を返します)。
Definition at line 629 of file potrHealthThread.c.
References PotrContext_::global, PotrGlobalConfig::health_interval_ms, PotrContext_::health_running, PotrContext_::health_thread, POTR_ERROR, POTR_LOG, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, s_health_args, PotrContext_::service, PotrServiceDef::service_id, and tcp_health_thread_func().
Referenced by start_connected_threads().
| int potr_tcp_health_thread_stop | ( | struct PotrContext_ * | ctx, |
| int | path_idx ) |
TCP ヘルスチェックスレッドを停止します。
| [in,out] | ctx | セッションコンテキストへのポインタ。 |
| [in] | path_idx | パスインデックス (0 ~ n_path-1)。 |
Definition at line 681 of file potrHealthThread.c.
References PotrContext_::health_mutex, PotrContext_::health_running, PotrContext_::health_thread, PotrContext_::health_wakeup, POTR_ERROR, and POTR_SUCCESS.
Referenced by stop_connected_threads().
|
static |
Definition at line 62 of file potrHealthThread.c.
Referenced by potr_tcp_health_thread_start().