plptools
Loading...
Searching...
No Matches
ncp_session.cc File Reference
#include "config.h"
#include "ncp_session.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <plpintl.h>
#include <pthread.h>
#include "ncp_log.h"
#include "socketchannel.h"
Include dependency graph for ncp_session.cc:

Go to the source code of this file.

Functions

void * link_thread (void *arg)
 
void * socket_connection_polling_thread (void *arg)
 Responsible for driving the SocketChannel instances (incoming TCP connections) by means of SocketChannel::socketPoll. More...
 
void check_for_new_socket_connection (NCPSession *session)
 
void * ncp_session_main_thread (void *arg)
 

Function Documentation

◆ check_for_new_socket_connection()

void check_for_new_socket_connection ( NCPSession session)

Definition at line 123 of file ncp_session.cc.

◆ link_thread()

void * link_thread ( void *  arg)
Todo:
There's something really nuanced going on with the use of the NCPSession::socketChannelWatch_ here. Specifically, while it might look like it's just being used as a timeout (which might be the intent), new TCP sockets are added to it on a successful accept, meaning that this will wake up frequently whenever there's activity on the socket. This will cause frequent NCP::hasFailed checks, and very timely resets (NCP::reset) whenever a client is connected. It's possible this was introduced as a work-around to connectivity issues. It is also worth noting that IOWatch is not thread-safe, so using it in link_thread, and adding to it in ncp_session_main_thread (as we are doing) is definitely a bad thing.

The NCP::reset call here is currently required (even though it feels like it shouldn't be) as it's responsible for preparing the stack after a successful connection has ended (packet currently has responsibility for performing internal resets when auto-detecting baud rate).

Definition at line 51 of file ncp_session.cc.

◆ ncp_session_main_thread()

void * ncp_session_main_thread ( void *  arg)

Definition at line 171 of file ncp_session.cc.

◆ socket_connection_polling_thread()

void * socket_connection_polling_thread ( void *  arg)

Responsible for driving the SocketChannel instances (incoming TCP connections) by means of SocketChannel::socketPoll.

This isn't likely to scale particularly well as it polls all connected sockets whenever a single one wakes up, but it seems to work (as we never have that many connected clients).

Definition at line 78 of file ncp_session.cc.