|
Document of c-modernization-kit (porter) 1.0.0
|
非同期送信スレッドの実装。 More...
#include <pthread.h>#include <sys/socket.h>#include <netinet/in.h>#include <time.h>#include <poll.h>#include <string.h>#include <inttypes.h>#include <porter_const.h>#include "../potrContext.h"#include "../potrPeerTable.h"#include "../infra/potrSendQueue.h"#include "potrSendThread.h"#include "../protocol/packet.h"#include "../protocol/window.h"#include "../infra/potrLog.h"#include "../infra/crypto/crypto.h"Go to the source code of this file.
Functions | |
| static uint64_t | get_ms (void) |
| static void | append_payload_elem (uint8_t *packed_buf, size_t *packed_len, const PotrPayloadElem *entry) |
| static int | tcp_send_all (PotrSocket fd, PotrMutex *mtx, const uint8_t *buf, size_t len) |
| static void | flush_packed (struct PotrContext_ *ctx, size_t packed_len) |
| static void | flush_packed_peer (struct PotrContext_ *ctx, PotrPeerContext *peer, size_t packed_len) |
| static void | send_packed_peer_mode (struct PotrContext_ *ctx, PotrPayloadElem *first) |
| static void * | send_thread_func (void *arg) |
| int | potr_send_thread_start (struct PotrContext_ *ctx) |
| void | potr_send_thread_stop (struct PotrContext_ *ctx) |
非同期送信スレッドの実装。
送信キュー (PotrSendQueue) からペイロードエレメントを取り出して 外側パケット (POTR_FLAG_DATA) を構築し sendto を呼び出す送信スレッド。
potrOpenService (POTR_ROLE_SENDER) 時に起動し、potrCloseService 時に停止します。
potrSend の flags 引数の値によらず常に起動しており、 ノンブロッキング送信 (POTR_SEND_BLOCKING なし) 時のみキューが使用されます。
Definition in file potrSendThread.c.
|
static |
Definition at line 61 of file potrSendThread.c.
Referenced by flush_packed(), flush_packed_peer(), and send_thread_func().
|
static |
Definition at line 73 of file potrSendThread.c.
References PotrPayloadElem::flags, PotrPayloadElem::payload, and PotrPayloadElem::payload_len.
Referenced by send_packed_peer_mode(), and send_thread_func().
|
static |
Definition at line 87 of file potrSendThread.c.
References POTR_ERROR, and POTR_SUCCESS.
Referenced by flush_packed().
|
static |
Definition at line 120 of file potrSendThread.c.
References PotrContext_::buf_full_suppress_cnt, PotrContext_::crypto_buf, PotrContext_::crypto_buf_size, PotrContext_::dest_addr, PotrServiceDef::encrypt_enabled, PotrServiceDef::encrypt_key, PotrPacket::flags, get_ms(), PotrContext_::health_mutex, PotrContext_::health_running, PotrContext_::health_wakeup, PotrContext_::last_send_ms, PotrContext_::n_path, PotrWindow::next_seq, packet_build_packed(), PACKET_HEADER_SIZE, PotrPacket::payload_len, POTR_CRYPTO_NONCE_SIZE, POTR_CRYPTO_TAG_SIZE, potr_encrypt(), POTR_FLAG_ENCRYPTED, POTR_INVALID_SOCKET, potr_is_tcp_type(), POTR_LOG, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, PotrContext_::send_window, PotrContext_::send_window_mutex, PotrContext_::send_wire_buf, 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_::sock, PotrContext_::tcp_active_paths, PotrContext_::tcp_conn_fd, tcp_send_all(), PotrContext_::tcp_send_mutex, PotrServiceDef::type, and window_send_push().
Referenced by send_thread_func().
|
static |
Definition at line 369 of file potrSendThread.c.
References PotrContext_::crypto_buf, PotrContext_::crypto_buf_size, PotrPeerContext_::dest_addr, PotrServiceDef::encrypt_enabled, PotrServiceDef::encrypt_key, PotrPacket::flags, get_ms(), PotrContext_::last_send_ms, PotrWindow::next_seq, packet_build_packed(), PACKET_HEADER_SIZE, PotrPacket::payload_len, PotrPeerContext_::peer_id, POTR_CRYPTO_NONCE_SIZE, POTR_CRYPTO_TAG_SIZE, potr_encrypt(), POTR_FLAG_ENCRYPTED, POTR_LOG, POTR_MAX_PATH, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, PotrPeerContext_::send_window, PotrPeerContext_::send_window_mutex, PotrContext_::send_wire_buf, PotrPacket::seq_num, PotrContext_::service, PotrPacketSessionHdr::service_id, PotrServiceDef::service_id, PotrPacket::session_id, PotrPacketSessionHdr::session_id, PotrPeerContext_::session_id, PotrPacketSessionHdr::session_tv_nsec, PotrPeerContext_::session_tv_nsec, PotrPacketSessionHdr::session_tv_sec, PotrPeerContext_::session_tv_sec, PotrContext_::sock, and window_send_push().
Referenced by send_packed_peer_mode().
|
static |
Definition at line 493 of file potrSendThread.c.
References append_payload_elem(), PotrServiceDef::encrypt_enabled, PotrPayloadElem::flags, flush_packed_peer(), PotrContext_::global, PotrGlobalConfig::max_payload, PACKET_HEADER_SIZE, PotrPayloadElem::payload_len, peer_find_by_id(), PotrPayloadElem::peer_id, PotrContext_::peers_mutex, POTR_CRYPTO_TAG_SIZE, POTR_FLAG_MORE_FRAG, POTR_PAYLOAD_ELEM_HDR_SIZE, potr_send_queue_complete(), potr_send_queue_peek(), potr_send_queue_try_pop(), POTR_SUCCESS, PotrContext_::send_queue, PotrContext_::send_wire_buf, and PotrContext_::service.
Referenced by send_thread_func().
|
static |
Definition at line 566 of file potrSendThread.c.
References append_payload_elem(), PotrServiceDef::encrypt_enabled, PotrPayloadElem::flags, flush_packed(), get_ms(), PotrContext_::global, PotrContext_::is_multi_peer, PotrGlobalConfig::max_payload, PotrServiceDef::pack_wait_ms, PACKET_HEADER_SIZE, PotrPayloadElem::payload_len, POTR_CRYPTO_TAG_SIZE, POTR_FLAG_MORE_FRAG, POTR_PAYLOAD_ELEM_HDR_SIZE, potr_send_queue_complete(), potr_send_queue_peek(), potr_send_queue_peek_timed(), potr_send_queue_pop(), potr_send_queue_try_pop(), POTR_SUCCESS, send_packed_peer_mode(), PotrContext_::send_queue, PotrContext_::send_thread_running, PotrContext_::send_wire_buf, and PotrContext_::service.
Referenced by potr_send_thread_start().
| int potr_send_thread_start | ( | struct PotrContext_ * | ctx | ) |
Definition at line 710 of file potrSendThread.c.
References POTR_ERROR, POTR_SUCCESS, PotrContext_::send_thread, send_thread_func(), PotrContext_::send_thread_running, and PotrContext_::send_window_mutex.
Referenced by potrOpenService(), and start_connected_threads().
| void potr_send_thread_stop | ( | struct PotrContext_ * | ctx | ) |
Definition at line 737 of file potrSendThread.c.
References potr_send_queue_shutdown(), PotrContext_::send_queue, PotrContext_::send_thread, PotrContext_::send_thread_running, and PotrContext_::send_window_mutex.
Referenced by potr_connect_thread_stop(), potrCloseService(), potrOpenService(), and start_connected_threads().