All communication to and from other runtimes. More...
#include "runtime_communication.h"
#include "logging.h"
#include "communication.h"
#include "msu_message.h"
#include "inter_runtime_messages.h"
#include "local_msu.h"
#include "runtime_dfg.h"
#include "thread_message.h"
#include "rt_stats.h"
#include "socket_monitor.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <stdlib.h>
#include <unistd.h>
Go to the source code of this file.
Classes | |
struct | runtime_peer |
Holds the file descriptor for a single runtime peer. More... | |
Macros | |
#define | MAX_RUNTIME_ID 32 |
Maximum number of other runtimes that can connect to this one. More... | |
Functions | |
int | send_to_peer (unsigned int runtime_id, struct inter_runtime_msg_hdr *hdr, void *payload) |
Sends a message to the peer runtime with the provided id. More... | |
int | add_runtime_peer (unsigned int runtime_id, int fd) |
Adds the file descriptor to the list of current runtime peers. More... | |
static int | send_init_msg (int id) |
Sends the inter_runtime_init message to the runtime with the given ID. More... | |
int | connect_to_runtime_peer (unsigned int id, struct sockaddr_in *addr) |
Innitiates a connection to a runtime peer with the given ID at the given address. More... | |
int | init_runtime_socket (int listen_port) |
Initializes the socket listening for incoming connections. More... | |
static int | read_runtime_message_hdr (int fd, struct inter_runtime_msg_hdr *msg) |
Reads a header from a peer runtime. More... | |
static int | process_fwd_to_msu_message (size_t payload_size, int msu_id, int fd) |
static int | process_init_rt_message (size_t payload_size, int fd) |
Processes an init message which has just been received from another runtime. More... | |
static int | process_runtime_message_hdr (struct inter_runtime_msg_hdr *hdr, int fd) |
Processes the header which has been received on fd , and processes the header's payload. More... | |
int | handle_runtime_communication (int fd) |
Reads a message off of the provided file descriptor as if it is coming from a runtime peer. More... | |
Variables | |
static int | runtime_sock = -1 |
Static (global) variable for the socket listening for other runtimes. More... | |
static struct runtime_peer | runtime_peers [32] |
Other runtime peer sockets. More... | |
All communication to and from other runtimes.
Definition in file runtime_communication.c.
#define MAX_RUNTIME_ID 32 |
Maximum number of other runtimes that can connect to this one.
Definition at line 56 of file runtime_communication.c.
int add_runtime_peer | ( | unsigned int | runtime_id, |
int | fd | ||
) |
Adds the file descriptor to the list of current runtime peers.
Definition at line 97 of file runtime_communication.c.
int connect_to_runtime_peer | ( | unsigned int | id, |
struct sockaddr_in * | addr | ||
) |
Innitiates a connection to a runtime peer with the given ID at the given address.
Only to be called from the output thread
Definition at line 150 of file runtime_communication.c.
int handle_runtime_communication | ( | int | fd | ) |
Reads a message off of the provided file descriptor as if it is coming from a runtime peer.
Definition at line 286 of file runtime_communication.c.
int init_runtime_socket | ( | int | listen_port | ) |
Initializes the socket listening for incoming connections.
Definition at line 177 of file runtime_communication.c.
|
static |
Definition at line 204 of file runtime_communication.c.
|
static |
Processes an init message which has just been received from another runtime.
Definition at line 237 of file runtime_communication.c.
|
static |
Processes the header which has been received on fd
, and processes the header's payload.
Definition at line 262 of file runtime_communication.c.
|
static |
Reads a header from a peer runtime.
Definition at line 193 of file runtime_communication.c.
|
static |
Sends the inter_runtime_init message to the runtime with the given ID.
Definition at line 125 of file runtime_communication.c.
int send_to_peer | ( | unsigned int | runtime_id, |
struct inter_runtime_msg_hdr * | hdr, | ||
void * | payload | ||
) |
Sends a message to the peer runtime with the provided id.
runtime_id | The ID of the runtime to which the message is to be sent |
hdr | The header of the inter-runtime message |
payload | The message to be sent |
Definition at line 64 of file runtime_communication.c.
|
static |
Other runtime peer sockets.
Structs will be initialized to 0 due to static initialization.
Definition at line 62 of file runtime_communication.c.
|
static |
Static (global) variable for the socket listening for other runtimes.
Definition at line 46 of file runtime_communication.c.