Monitors an incoming port for messages from runtime or controller. More...
#include "epollops.h"
#include "communication.h"
#include "logging.h"
#include "controller_communication.h"
#include "runtime_communication.h"
#include <sys/epoll.h>
Go to the source code of this file.
Macros | |
#define | MAX_RUNTIME_FD 1024 |
The maximum file descriptor that can be associated with a runtime. More... | |
Functions | |
static int | init_socket_monitor (int port) |
Initializes the socket monitor on the given port. More... | |
static int | handle_connection (int fd, void *data) |
Checks if the file descriptor is a runtime or controller, and handles it appropraitely. More... | |
static int | accept_connection (int fd, void *data) |
Accepts a new connection. More... | |
static int | socket_monitor_epoll_loop () |
The main loop for the socket monitor. More... | |
int | monitor_controller_socket (int new_fd) |
Adds the global controller to be monitored by the socket monitor. More... | |
int | monitor_runtime_socket (int new_fd) |
Adds a runtime to be monitored by the socket monitor. More... | |
int | run_socket_monitor (int local_port, struct sockaddr_in *ctrl_addr) |
Starts (blocking) the socket monitor, listening on the provided port. More... | |
Variables | |
static bool | runtime_fds [1024] |
Whether the file descriptor has been associated with a runtime. More... | |
int | runtime_socket = -1 |
The socket on which incoming connections are monitored. More... | |
int | epoll_fd = -1 |
The epoll file descriptor monitoring sockets. More... | |
Monitors an incoming port for messages from runtime or controller.
Definition in file socket_monitor.c.
#define MAX_RUNTIME_FD 1024 |
The maximum file descriptor that can be associated with a runtime.
Definition at line 34 of file socket_monitor.c.
|
static |
|
static |
Checks if the file descriptor is a runtime or controller, and handles it appropraitely.
Definition at line 69 of file socket_monitor.c.
|
static |
Initializes the socket monitor on the given port.
Definition at line 44 of file socket_monitor.c.
int monitor_controller_socket | ( | int | fd | ) |
Adds the global controller to be monitored by the socket monitor.
fd | the file decriptor of the global controller |
Definition at line 116 of file socket_monitor.c.
int monitor_runtime_socket | ( | int | fd | ) |
Adds a runtime to be monitored by the socket monitor.
fd | the file descriptor of the new runtime |
Definition at line 130 of file socket_monitor.c.
int run_socket_monitor | ( | int | local_port, |
struct sockaddr_in * | ctrl_addr | ||
) |
Starts (blocking) the socket monitor, listening on the provided port.
Also connects to the global controller at the provided address
Definition at line 145 of file socket_monitor.c.
|
static |
The main loop for the socket monitor.
Simply calls epoll_loop
Definition at line 101 of file socket_monitor.c.
int epoll_fd = -1 |
The epoll file descriptor monitoring sockets.
Definition at line 41 of file socket_monitor.c.
|
static |
Whether the file descriptor has been associated with a runtime.
Definition at line 36 of file socket_monitor.c.
int runtime_socket = -1 |
The socket on which incoming connections are monitored.
Definition at line 39 of file socket_monitor.c.