45 log(LOG_WEBSERVER_READ,
"Attempting read from %p", read_state);
49 log(LOG_WEBSERVER_READ,
"Read incomplete. Re-enabling (fd: %d)", read_state->
conn.
fd);
56 log(LOG_WEBSERVER_READ,
"Error when reading from socket!");
58 log(LOG_WEBSERVER_READ,
"Error when reading from socket!");
60 log(LOG_WEBSERVER_READ,
"Error when reading from socket!");
64 log(LOG_WEBSERVER_READ,
"Read %s", read_state->
req);
66 struct read_state *out = malloc(
sizeof(*out));
67 memcpy(out, read_state,
sizeof(*read_state));
80 rtn =
handle_read(read_state, msu_state,
self, msg);
101 switch (sender_type_id) {
107 log(LOG_WEBSERVER_READ,
"Got back read msg %u", msg->
hdr.
key.
id);
111 log_error(
"Unknown sender MSU type ID: %d", sender_type_id);
117 if (read_state == NULL) {
121 log(LOG_WEBSERVER_READ,
"Retrieved read ptr %p", read_state);
123 if (read_state->
conn.
fd != conn_in.
fd) {
124 log_error(
"Got non-matching FDs! state: %d vs input: %d", read_state->
conn.
fd, conn_in.
fd);
136 return handle_read(read_state, msu_state,
self, msg);
143 #define SSL_INIT_CMD "SSL"
150 if (init_cmd == NULL) {
151 log_info(
"Initializing NON-SSL webserver-reading MSU");
155 log_info(
"Initializing SSL webserver-reading MSU");
158 log_info(
"Initializing SSL webserver-reading MSU anyway");
162 self->msu_state = (
void*)ws_state;
167 free(self->msu_state);
181 log_error(
"Error loading SSL cert %s", pem_file);
185 signal(SIGPIPE, SIG_IGN);
195 .
name =
"Webserver_read_MSU",
void kill_ssl_locks(void)
void init_ssl_locks(void)
int msu_error(struct local_msu *msu, struct msu_msg_hdr *hdr, int broadcast)
Macro for declaring functions or variables as unused to avoid compiler warnings.
void init_connection(struct connection *conn, int fd)
#define log_info(fmt,...)
int msu_remove_fd_monitor(int fd)
static int init_ssl_ctx(struct msu_type UNUSED *type)
static int ws_read_init(struct local_msu *self, struct msu_init_data *data)
void * msu_get_state(struct local_msu *msu, struct msu_msg_key *key, size_t *size)
Gets the state allocated with the given key.
static int handle_read(struct read_state *read_state, struct ws_read_state *msu_state, struct local_msu *self, struct msu_msg *msg)
#define log_critical(fmt,...)
struct msu_type WEBSERVER_HTTP_MSU_TYPE
unsigned int msu_msg_sender_type(struct msg_provinance *prov)
State storage that is tied to a specific MSU mesasge.
int32_t id
A shorter, often hashed id for the key of fixed length (used in routing)
#define WS_INCOMPLETE_READ
#define SOCKET_MSU_TYPE_ID
Logging of status messages to the terminal.
Access local files within the repo.
#define WS_INCOMPLETE_WRITE
int close_connection(struct connection *conn)
void * msu_init_state(struct local_msu *msu, struct msu_msg_key *key, size_t size)
Initializes a new MSU state of the given size with the provided key.
static int handle_accept(struct read_state *read_state, struct ws_read_state *msu_state, struct local_msu *self, struct msu_msg *msg)
int load_ssl_certificate(char *cert_file, char *key_file)
struct msu_type WEBSERVER_READ_MSU_TYPE
Declares the methods available for calling an MSU from another MSU.
void init_read_state(struct read_state *state, struct connection *conn)
static void ws_read_destroy(struct local_msu *self)
struct msg_provinance provinance
Message history.
#define log_error(fmt,...)
Declares the structures and functions applicable to MSUs on the local machine.
static int read_http_request(struct local_msu *self, struct msu_msg *msg)
The structure that represents an MSU located on the local machine.
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
Functions for routing MSU messages between MSUs.
int get_local_file(char *out, char *file)
Gets a file relative to the path of the executable.
The structure contining msu state.
int call_msu_type(struct local_msu *sender, struct msu_type *dst_type, struct msu_msg_hdr *hdr, size_t data_size, void *data)
Sends an MSU message to a destination of the given type, utilizing the sending MSU's routing function...
#define WEBSERVER_READ_MSU_TYPE_ID
int init_ssl_context(void)
#define RTN_TO_EVT(rtn__)
static int accept_connection(int fd, void *data)
Accepts a new connection.
#define WEBSERVER_HTTP_MSU_TYPE_ID
int msu_monitor_fd(int fd, uint32_t events, struct local_msu *destination, struct msu_msg_hdr *hdr)
#define log(level, fmt,...)
Log at a custom level.
A message that is to be delivered to an instance of an MSU.
int read_request(struct read_state *state)
int msu_free_state(struct local_msu *msu, struct msu_msg_key *key)
Frees the state assocated with the given MSU and key.
char * name
Name for the msu type.
int route_to_origin_runtime(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Routes an MSU message to the runtime on which the message originated.
static void destroy_ssl_ctx(struct msu_type UNUSED *type)
Declares strategies that MSUs can use for routing to endpoints.
struct msu_msg_key key
Routing/state key.
enum webserver_status status