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

potrDisconnectPeer 関数の実装。 More...

#include <inttypes.h>
#include <porter_const.h>
#include <porter.h>
#include "../potrContext.h"
#include "../potrPeerTable.h"
#include "../infra/potrLog.h"
#include <pthread.h>
Include dependency graph for potrDisconnectPeer.c:

Go to the source code of this file.

Macros

#define POTR_MUTEX_LOCK_LOCAL(m)
#define POTR_MUTEX_UNLOCK_LOCAL(m)

Typedefs

typedef pthread_mutex_t PotrMutexLocal

Functions

POTR_EXPORT int POTR_API potrDisconnectPeer (PotrHandle handle, PotrPeerId peer_id)
 指定ピアを切断します (N:1 モード専用)。

Detailed Description

potrDisconnectPeer 関数の実装。

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

Definition in file potrDisconnectPeer.c.

Macro Definition Documentation

◆ POTR_MUTEX_LOCK_LOCAL

#define POTR_MUTEX_LOCK_LOCAL ( m)
Value:
pthread_mutex_lock(m)

Definition at line 25 of file potrDisconnectPeer.c.

Referenced by potrDisconnectPeer().

◆ POTR_MUTEX_UNLOCK_LOCAL

#define POTR_MUTEX_UNLOCK_LOCAL ( m)
Value:
pthread_mutex_unlock(m)

Definition at line 26 of file potrDisconnectPeer.c.

Referenced by potrDisconnectPeer().

Typedef Documentation

◆ PotrMutexLocal

typedef pthread_mutex_t PotrMutexLocal

Definition at line 24 of file potrDisconnectPeer.c.

Function Documentation

◆ potrDisconnectPeer()

POTR_EXPORT int POTR_API potrDisconnectPeer ( PotrHandle handle,
PotrPeerId peer_id )

指定ピアを切断します (N:1 モード専用)。

Parameters
[in]handlepotrOpenService() で取得したセッションハンドル。
[in]peer_id切断するピアの識別子 (POTR_PEER_NA および POTR_PEER_ALL 以外)。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

指定したピアへ FIN パケットを送信し、ピアのリソースを解放します。
切断完了後に POTR_EVENT_DISCONNECTED コールバックが発火します。
N:1 モード (unicast_bidir かつ src 情報省略) 専用です。
1:1 モードおよびその他の通信種別では POTR_ERROR を返します。

スレッド セーフティ
本関数はスレッドセーフです。
内部で peers_mutex により排他制御されるため、複数スレッドから並行して呼び出せます。
ただし PotrRecvCallback の内部から本関数を呼び出すとデッドロックが発生します。
コールバック内からの呼び出しは避けてください。
Warning
handle が NULL の場合は失敗を返します。
peer_id = POTR_PEER_NA または POTR_PEER_ALL の場合は失敗を返します。
指定した peer_id が存在しない場合は失敗を返します。
1:1 モードまたは N:1 モード以外で呼び出した場合は失敗を返します。

Definition at line 35 of file potrDisconnectPeer.c.

References PotrContext_::callback, PotrPeerContext_::health_alive, PotrContext_::is_multi_peer, peer_find_by_id(), peer_free(), PotrPeerContext_::peer_id, peer_send_fin(), PotrContext_::peers_mutex, POTR_API, POTR_ERROR, POTR_EVENT_DISCONNECTED, POTR_EXPORT, POTR_LOG, POTR_MUTEX_LOCK_LOCAL, POTR_MUTEX_UNLOCK_LOCAL, POTR_PEER_ALL, POTR_PEER_NA, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_INFO, PotrContext_::service, and PotrServiceDef::service_id.

Here is the call graph for this function: