The Pedigree Project 0.1
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
UnixSocketSyscalls Class Reference
+ Inheritance diagram for UnixSocketSyscalls:
+ Collaboration diagram for UnixSocketSyscalls:

Classes

class  EndpointMutationGuard
 
class  EndpointMutationPairGuard
 
class  EndpointReadinessGuard
 

Public Member Functions

 UnixSocketSyscalls (int domain, int type, int protocol)
 
virtual bool create ()
 Implementation-specific final socket creation logic.
 
virtual int connect (const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual ssize_t sendto_msg (const struct msghdr *msghdr, const SharedPointer< SocketRights > &rights)
 
virtual ssize_t recvfrom_msg (struct msghdr *msghdr, SharedPointer< SocketRights > *rights)
 
virtual int listen (int backlog)
 
virtual int bind (const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual int accept (struct sockaddr_storage *address, socklen_t *addrlen, int flags, DescriptorLease *accepted=nullptr)
 
virtual int shutdown (int how)
 
virtual int getpeername (struct sockaddr_storage *address, socklen_t *address_len)
 
virtual int getsockname (struct sockaddr_storage *address, socklen_t *address_len)
 
virtual int setsockopt (int level, int optname, const void *optvalue, socklen_t optlen)
 
virtual int getsockopt (int level, int optname, void *optvalue, socklen_t *optlen)
 
virtual bool canPoll () const
 
virtual bool poll (bool &read, bool &write, bool &error, Semaphore *waiter)
 
virtual void unPoll (Semaphore *waiter)
 
virtual ReadyMask queryReady (bool reading, bool writing)
 
ReadinessGenerations readinessGenerations () override
 
virtual void lastDescriptorClosed ()
 
virtual bool monitor (Thread *pThread, Event *pEvent)
 
virtual bool unmonitor (Event *pEvent)
 
bool pairWith (UnixSocketSyscalls *other)
 
- Public Member Functions inherited from NetworkSyscalls
 NetworkSyscalls (int domain, int type, int protocol)
 
virtual ssize_t sendto (const void *buffer, size_t bufferlen, int flags, const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual ssize_t recvfrom (void *buffer, size_t bufferlen, int flags, struct sockaddr_storage *address, socklen_t *addrlen)
 
MUST_USE_RESULT bool addDescriptorOwner ()
 
void removeDescriptorOwner ()
 
void retainDescriptorLifetime (const SharedPointer< NetworkSyscalls > &lifetime)
 
void associate (FileDescriptor *fd)
 
int getDomain () const
 
int getType () const
 
int getProtocol () const
 
bool isBlocking () const
 
virtual void setBlocking (bool blocking)
 
int takeReceiveError ()
 
void deferReceiveError (int error)
 
- Public Member Functions inherited from ReadinessSource
MUST_USE_RESULT bool subscribeReadiness (ReadyMask interest, const SharedPointer< ReadinessObserver > &observer, ReadinessSubscription &subscription)
 

Private Member Functions

 NOT_COPYABLE_OR_ASSIGNABLE (UnixSocketSyscalls)
 
void registerSocket (UnixSocket *socket)
 
void registerPeer (UnixSocket *socket, UnixSocket *peer, UnixSocket *listener=nullptr)
 
void unregisterPeer (UnixSocket *socket, UnixSocket *peer)
 
void notifyPeer (UnixSocket *socket, ReadyMask mask)
 
SharedPointer< UnixSocketGenerationacquireLocalEndpoint () const
 
void replaceLocalEndpoint (UnixSocket *socket, bool tracked, const String *localPath=nullptr)
 
void tryCompleteEndpointClose ()
 
UnixSocket::SocketType getSocketType () const
 

Static Private Member Functions

static void unregisterSocket (UnixSocket *socket, List< UnixSocket * > &peers)
 
static void notifySocket (UnixSocket *socket, ReadyMask mask)
 

Private Attributes

Mutex m_EndpointStateLock
 
Mutex m_EndpointMutationLock
 
Atomic< bool > m_EndpointMutationReleaseInProgress
 
Atomic< bool > m_EndpointClosePending
 
Atomic< bool > m_EndpointRetired
 
Atomic< bool > m_EndpointCloseFinalized
 
SharedPointer< UnixSocketGenerationm_LocalEndpoint
 
SharedPointer< UnixSocketReferencem_RemoteEndpoint
 
SharedPointer< UnixSocketGenerationm_ClosingLocalEndpoint
 
SharedPointer< UnixSocketReferencem_ClosingRemoteEndpoint
 
String m_LocalPath
 
String m_RemotePath
 

Static Private Attributes

static Tree< UnixSocket *, UnixSocketSyscalls * > m_SyscallObjects
 
static Tree< UnixSocket *, UnixSocket * > m_Peers
 
static Tree< UnixSocket *, UnixSocket * > m_PendingListeners
 
static Mutex m_SyscallObjectsLock
 

Friends

class UnixSocketGeneration
 
bool runHostedUnixEndpointLifetimeRegression (Process *process)
 

Additional Inherited Members

- Protected Member Functions inherited from NetworkSyscalls
ReadyMask pendingReceiveReadiness () const
 
ReadinessGenerations withReceiveErrorGeneration (ReadinessGenerations generations) const
 
bool beginDescriptorClose ()
 
bool hasLastDescriptorClosed () const
 
SharedPointer< NetworkSyscallsacquireDescriptorLifetime () const
 
SharedPointer< NetworkSyscallsreleaseDescriptorLifetime ()
 
- Protected Member Functions inherited from ReadinessSource
void notifyReadiness (ReadyMask mask)
 
void closeReadiness (ReadyMask mask=ReadyInvalid|ReadyHangup)
 
- Protected Attributes inherited from NetworkSyscalls
int m_Domain
 
int m_Type
 
int m_Protocol
 
Atomic< bool > m_Blocking
 
Mutex m_ReceiveErrorLock
 
int m_ReceiveError = 0
 
uint64_t m_ReceiveErrorGeneration = 0
 
OperationBarrier m_ReadinessNotifications
 

Detailed Description

Definition at line 265 of file net-syscalls.h.

Constructor & Destructor Documentation

◆ UnixSocketSyscalls()

UnixSocketSyscalls::UnixSocketSyscalls ( int  domain,
int  type,
int  protocol 
)

Definition at line 2882 of file net-syscalls.cc.

◆ ~UnixSocketSyscalls()

UnixSocketSyscalls::~UnixSocketSyscalls ( )
virtual

Definition at line 2897 of file net-syscalls.cc.

Member Function Documentation

◆ accept()

int UnixSocketSyscalls::accept ( struct sockaddr_storage *  address,
socklen_t *  addrlen,
int  flags,
DescriptorLease accepted = nullptr 
)
virtual

Implements NetworkSyscalls.

Definition at line 3684 of file net-syscalls.cc.

◆ acquireLocalEndpoint()

SharedPointer< UnixSocketGeneration > UnixSocketSyscalls::acquireLocalEndpoint ( ) const
private

Definition at line 3022 of file net-syscalls.cc.

◆ bind()

int UnixSocketSyscalls::bind ( const struct sockaddr_storage *  address,
socklen_t  addrlen 
)
virtual

◆ canPoll()

bool UnixSocketSyscalls::canPoll ( ) const
virtual

Reimplemented from NetworkSyscalls.

Definition at line 3884 of file net-syscalls.cc.

◆ connect()

int UnixSocketSyscalls::connect ( const struct sockaddr_storage *  address,
socklen_t  addrlen 
)
virtual

◆ create()

bool UnixSocketSyscalls::create ( )
virtual

Implementation-specific final socket creation logic.

Reimplemented from NetworkSyscalls.

Definition at line 3123 of file net-syscalls.cc.

References SharedPointer< T >::get().

◆ getpeername()

int UnixSocketSyscalls::getpeername ( struct sockaddr_storage *  address,
socklen_t *  address_len 
)
virtual

Implements NetworkSyscalls.

Definition at line 3753 of file net-syscalls.cc.

◆ getSocketType()

UnixSocket::SocketType UnixSocketSyscalls::getSocketType ( ) const
private

Definition at line 4069 of file net-syscalls.cc.

◆ getsockname()

int UnixSocketSyscalls::getsockname ( struct sockaddr_storage *  address,
socklen_t *  address_len 
)
virtual

Implements NetworkSyscalls.

Definition at line 3780 of file net-syscalls.cc.

◆ getsockopt()

int UnixSocketSyscalls::getsockopt ( int  level,
int  optname,
void *  optvalue,
socklen_t *  optlen 
)
virtual

Implements NetworkSyscalls.

Definition at line 3817 of file net-syscalls.cc.

◆ lastDescriptorClosed()

void UnixSocketSyscalls::lastDescriptorClosed ( )
virtual

Retire the transport after the final descriptor alias closes.

Readiness users may retain this wrapper after the transport is gone, so implementations leave queryReady() returning a stable terminal state.

Reimplemented from NetworkSyscalls.

Definition at line 3049 of file net-syscalls.cc.

References NetworkSyscalls::beginDescriptorClose(), OperationBarrier::close(), Mutex::isOwnedByCurrentThread(), m_EndpointMutationLock, and NetworkSyscalls::m_ReadinessNotifications.

◆ listen()

int UnixSocketSyscalls::listen ( int  backlog)
virtual
Todo:
bind to an unnamed socket if we aren't already bound

Implements NetworkSyscalls.

Definition at line 3559 of file net-syscalls.cc.

References SharedPointer< T >::get().

◆ monitor()

bool UnixSocketSyscalls::monitor ( Thread pThread,
Event pEvent 
)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 3996 of file net-syscalls.cc.

◆ notifyPeer()

void UnixSocketSyscalls::notifyPeer ( UnixSocket socket,
ReadyMask  mask 
)
private

Definition at line 3010 of file net-syscalls.cc.

◆ notifySocket()

void UnixSocketSyscalls::notifySocket ( UnixSocket socket,
ReadyMask  mask 
)
staticprivate

Definition at line 2991 of file net-syscalls.cc.

◆ pairWith()

bool UnixSocketSyscalls::pairWith ( UnixSocketSyscalls other)

Pair two UnixSocketSyscalls objects such that the referenced sockets directly communicate with each other.

Definition at line 4016 of file net-syscalls.cc.

References SharedPointer< T >::get(), m_EndpointMutationLock, m_EndpointStateLock, and ReadinessSource::notifyReadiness().

◆ poll()

bool UnixSocketSyscalls::poll ( bool &  read,
bool &  write,
bool &  error,
Semaphore waiter 
)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 3947 of file net-syscalls.cc.

◆ queryReady()

ReadyMask UnixSocketSyscalls::queryReady ( bool  reading,
bool  writing 
)
virtual

Return a level-triggered snapshot for the requested I/O directions.

Reimplemented from NetworkSyscalls.

Definition at line 3888 of file net-syscalls.cc.

References SharedPointer< T >::get(), and UnixSocket::select().

◆ readinessGenerations()

ReadinessGenerations UnixSocketSyscalls::readinessGenerations ( )
overridevirtual

Return source-serialized rising-edge sequences where available.

A source increments the corresponding sequence while holding the same lock which changes its readiness predicate. Consumers can then recover a drain/refill transition even if the two callback deliveries are reordered.

Reimplemented from NetworkSyscalls.

Definition at line 3936 of file net-syscalls.cc.

References SharedPointer< T >::get().

◆ recvfrom_msg()

ssize_t UnixSocketSyscalls::recvfrom_msg ( struct msghdr *  msghdr,
SharedPointer< SocketRights > *  rights 
)
virtual

Implements NetworkSyscalls.

Definition at line 3417 of file net-syscalls.cc.

◆ registerPeer()

void UnixSocketSyscalls::registerPeer ( UnixSocket socket,
UnixSocket peer,
UnixSocket listener = nullptr 
)
private

Definition at line 2918 of file net-syscalls.cc.

◆ registerSocket()

void UnixSocketSyscalls::registerSocket ( UnixSocket socket)
private

Definition at line 2901 of file net-syscalls.cc.

◆ replaceLocalEndpoint()

void UnixSocketSyscalls::replaceLocalEndpoint ( UnixSocket socket,
bool  tracked,
const String localPath = nullptr 
)
private

Definition at line 3027 of file net-syscalls.cc.

◆ sendto_msg()

ssize_t UnixSocketSyscalls::sendto_msg ( const struct msghdr *  msghdr,
const SharedPointer< SocketRights > &  rights 
)
virtual

◆ setsockopt()

int UnixSocketSyscalls::setsockopt ( int  level,
int  optname,
const void *  optvalue,
socklen_t  optlen 
)
virtual

Implements NetworkSyscalls.

Definition at line 3800 of file net-syscalls.cc.

◆ shutdown()

int UnixSocketSyscalls::shutdown ( int  how)
virtual
Todo:

Reimplemented from NetworkSyscalls.

Definition at line 3747 of file net-syscalls.cc.

◆ tryCompleteEndpointClose()

void UnixSocketSyscalls::tryCompleteEndpointClose ( )
private

Definition at line 3069 of file net-syscalls.cc.

◆ unmonitor()

bool UnixSocketSyscalls::unmonitor ( Event pEvent)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 4006 of file net-syscalls.cc.

◆ unPoll()

void UnixSocketSyscalls::unPoll ( Semaphore waiter)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 3989 of file net-syscalls.cc.

◆ unregisterPeer()

void UnixSocketSyscalls::unregisterPeer ( UnixSocket socket,
UnixSocket peer 
)
private

Definition at line 2931 of file net-syscalls.cc.

◆ unregisterSocket()

void UnixSocketSyscalls::unregisterSocket ( UnixSocket socket,
List< UnixSocket * > &  peers 
)
staticprivate

Definition at line 2946 of file net-syscalls.cc.

Friends And Related Symbol Documentation

◆ UnixSocketGeneration

friend class UnixSocketGeneration
friend

Definition at line 306 of file net-syscalls.h.

Member Data Documentation

◆ m_ClosingLocalEndpoint

SharedPointer<UnixSocketGeneration> UnixSocketSyscalls::m_ClosingLocalEndpoint
private

Definition at line 381 of file net-syscalls.h.

◆ m_ClosingRemoteEndpoint

SharedPointer<UnixSocketReference> UnixSocketSyscalls::m_ClosingRemoteEndpoint
private

Definition at line 382 of file net-syscalls.h.

◆ m_EndpointCloseFinalized

Atomic<bool> UnixSocketSyscalls::m_EndpointCloseFinalized
private

Definition at line 378 of file net-syscalls.h.

◆ m_EndpointClosePending

Atomic<bool> UnixSocketSyscalls::m_EndpointClosePending
private

Definition at line 376 of file net-syscalls.h.

◆ m_EndpointMutationLock

Mutex UnixSocketSyscalls::m_EndpointMutationLock
private

Serializes bind/connect mutations without covering blocking I/O.

Definition at line 374 of file net-syscalls.h.

Referenced by lastDescriptorClosed(), and pairWith().

◆ m_EndpointMutationReleaseInProgress

Atomic<bool> UnixSocketSyscalls::m_EndpointMutationReleaseInProgress
private

Definition at line 375 of file net-syscalls.h.

◆ m_EndpointRetired

Atomic<bool> UnixSocketSyscalls::m_EndpointRetired
private

Definition at line 377 of file net-syscalls.h.

◆ m_EndpointStateLock

Mutex UnixSocketSyscalls::m_EndpointStateLock
mutableprivate

Serializes generation snapshots with endpoint and path publication.

Definition at line 372 of file net-syscalls.h.

Referenced by bind(), connect(), pairWith(), and sendto_msg().

◆ m_LocalEndpoint

SharedPointer<UnixSocketGeneration> UnixSocketSyscalls::m_LocalEndpoint
private

Definition at line 379 of file net-syscalls.h.

◆ m_LocalPath

String UnixSocketSyscalls::m_LocalPath
private

Definition at line 384 of file net-syscalls.h.

◆ m_Peers

Tree< UnixSocket *, UnixSocket * > UnixSocketSyscalls::m_Peers
staticprivate

Definition at line 313 of file net-syscalls.h.

◆ m_PendingListeners

Tree< UnixSocket *, UnixSocket * > UnixSocketSyscalls::m_PendingListeners
staticprivate

Definition at line 314 of file net-syscalls.h.

◆ m_RemoteEndpoint

SharedPointer<UnixSocketReference> UnixSocketSyscalls::m_RemoteEndpoint
private

Definition at line 380 of file net-syscalls.h.

◆ m_RemotePath

String UnixSocketSyscalls::m_RemotePath
private

Definition at line 385 of file net-syscalls.h.

◆ m_SyscallObjects

Tree< UnixSocket *, UnixSocketSyscalls * > UnixSocketSyscalls::m_SyscallObjects
staticprivate

Definition at line 312 of file net-syscalls.h.

◆ m_SyscallObjectsLock

Mutex UnixSocketSyscalls::m_SyscallObjectsLock
staticprivate

Definition at line 315 of file net-syscalls.h.


The documentation for this class was generated from the following files: