ray/src/common/io.h
Philipp Moritz 2068587af8 Fix socket bind collisions in manager_tests, race condition bind/listen/subscribe and memory leaks (#18)
* Fix socket bind collisions in manager_tests

* bind manager sockets before connecting to the store

* fix memory leak in tests

* fix valgrind early process termination

* fix bind/listen/subscribe race condition

* fix photon

* fix other tests

* make it that all of common is tested

* fix clang-format

* fix
2016-11-02 00:09:04 -07:00

33 lines
872 B
C

#ifndef IO_H
#define IO_H
#include <stdbool.h>
#include <stdint.h>
enum common_message_type {
/** Disconnect a client. */
DISCONNECT_CLIENT,
/** Log a message from a client. */
LOG_MESSAGE,
/** Submit a task to the local scheduler. */
SUBMIT_TASK,
};
/* Helper functions for socket communication. */
int bind_inet_sock(const int port, bool shall_listen);
int bind_ipc_sock(const char *socket_pathname, bool shall_listen);
int connect_ipc_sock(const char *socket_pathname);
int accept_client(int socket_fd);
/* Reading and writing data */
int write_message(int fd, int64_t type, int64_t length, uint8_t *bytes);
void read_message(int fd, int64_t *type, int64_t *length, uint8_t **bytes);
void write_log_message(int fd, char *message);
void write_formatted_log_message(int fd, const char *format, ...);
char *read_log_message(int fd);
#endif /* IO_H */