diff --git a/src/common/libremoteio.h b/src/common/libremoteio.h --- a/src/common/libremoteio.h +++ b/src/common/libremoteio.h @@ -20,10 +20,12 @@ #ifndef _DISTREN_LIBREMOTEIO_H #define _DISTREN_LIBREMOTEIO_H -#include "remoteio.h" +#include "common/multiio.h" +#include "common/remoteio.h" #include #include +#include /** private declarations for remoteio, to be included by options.c and remoteio.c @@ -37,7 +39,9 @@ enum remoteio_method #endif REMOTEIO_METHOD_TCP = 2, /* REMOETIO_METHOD_XMLRPC */ /*< maybe someday */ - REMOTEIO_METHOD_MAX = 3 /*< This is a number used to check the consitency of remoteio_server structs */ + /** method for the remoteio_open_socket() function, where we don't call open() ourselves: */ + REMOTEIO_METHOD_SOCKET = 3, + REMOTEIO_METHOD_MAX = 4 /*< This is a number used to check the consitency of remoteio_server structs */ }; struct remoteio_server @@ -53,15 +57,58 @@ struct remoteio_opts { char *ssh_command; list_t servers; /* type: (struct remoteio_server *) */ + /* store the multiio context for general use */ + multiio_context_t multiio; + /* store remoteio's socket_type */ + multiio_socket_type_t socket_type; + + /* an argument for the remoteio_read_handle_func_t */ + void *generic_handler_data; }; -struct remoteio { +/** + * Used to describe the nature of the data stored in the + * outbound and message queues that power remoteio_write() + * and remoteio_read() (?). + */ +struct remoteio_packet +{ + size_t len; + char *data; +}; + + +struct remoteio +{ enum remoteio_method method; struct remoteio_opts *opts; struct execio *execio; #ifndef WINDOWS int sock; #endif + + remoteio_read_handle_func_t read_handler; + /* for the read_handler */ + void *read_handler_data; + + /** + * Store a buffer of data waiting to be processed. + */ + struct remoteio_packet inbuf; + + /** + * Provide the asynchronosity abstraction by queuing outgoing messages. + */ + queue_t outmsgs; + + /** + * This is disappointingly hacky. If this variable is 0, then + * remoteio_close() will act normal. If set to 1, then + * remoteio_close() will not actually free this struct but instead + * increment this variable to 2. This is so that read_handler can + * call remoteio_close() without segfaulting us. + */ + short careful_free; };