#include "gras/Transport/transport_interface.h" /* gras_select */
typedef struct s_gras_msg_listener_ {
- xbt_queue_t incomming_messages; /* messages received from the wire and still to be used by master */
+ xbt_queue_t incomming_messages; /* messages received from the wire and still to be used by master */
xbt_queue_t socks_to_close; /* let the listener close the sockets, since it may be selecting on them. Darwin don't like this trick */
gras_socket_t wakeup_sock_listener_side;
gras_socket_t wakeup_sock_master_side;
- xbt_mutex_t init_mutex; /* both this mutex and condition are used at initialization to make sure that*/
- xbt_cond_t init_cond; /* the main thread speaks to the listener only once it is started (FIXME: It would be easier using a semaphore, if only semaphores were in xbt_synchro) */
+ xbt_mutex_t init_mutex; /* both this mutex and condition are used at initialization to make sure that */
+ xbt_cond_t init_cond; /* the main thread speaks to the listener only once it is started (FIXME: It would be easier using a semaphore, if only semaphores were in xbt_synchro) */
xbt_thread_t listener;
} s_gras_msg_listener_t;
gras_msg_t msg;
xbt_ex_t e;
gras_msgtype_t msg_wakeup_listener_t =
- gras_msgtype_by_name("_wakeup_listener");
+ gras_msgtype_by_name("_wakeup_listener");
DEBUG0("I'm the listener");
/* get a free socket for the receiving part of the listener */
- me->wakeup_sock_listener_side = gras_socket_server_range(5000, 6000, -1, 0);
+ me->wakeup_sock_listener_side =
+ gras_socket_server_range(5000, 6000, -1, 0);
/* wake up the launcher */
xbt_mutex_acquire(me->init_mutex);
msg = gras_msg_recv_any();
if (msg->type != msg_wakeup_listener_t) {
VERB1("Got a '%s' message. Queue it for handling by main thread",
- gras_msgtype_get_name(msg->type));
+ gras_msgtype_get_name(msg->type));
xbt_queue_push(me->incomming_messages, msg);
} else {
char got = *(char *) msg->payl;
xbt_queue_shift_timed(me->socks_to_close, &sock, 0);
if (tcp_close(sock) < 0) {
#ifdef _XBT_WIN32
- WARN2("error while closing tcp socket %d: %d\n", sock, sock_errno);
+ WARN2("error while closing tcp socket %d: %d\n", sock,
+ sock_errno);
#else
WARN3("error while closing tcp socket %d: %d (%s)\n",
sock, sock_errno, sock_errstr(sock_errno));
/* actually start the thread, and */
/* wait for the listener to initialize before we connect to its socket */
xbt_mutex_acquire(arg->init_mutex);
- arg->listener = xbt_thread_create("listener", listener_function, arg,1/*joinable*/);
+ arg->listener =
+ xbt_thread_create("listener", listener_function, arg,
+ 1 /*joinable */ );
xbt_cond_wait(arg->init_cond, arg->init_mutex);
xbt_mutex_release(arg->init_mutex);
xbt_cond_destroy(arg->init_cond);
/* Connect the other part of the socket */
arg->wakeup_sock_master_side =
- gras_socket_client(gras_os_myname(),
- gras_socket_my_port(arg->wakeup_sock_listener_side));
+ gras_socket_client(gras_os_myname(),
+ gras_socket_my_port
+ (arg->wakeup_sock_listener_side));
return arg;
}
DEBUG0("Listener quit");
if (pd->listener)
- gras_msg_send(pd->listener->wakeup_sock_master_side, "_wakeup_listener",
- &kill);
+ gras_msg_send(pd->listener->wakeup_sock_master_side,
+ "_wakeup_listener", &kill);
xbt_thread_join(pd->listener->listener);
DEBUG0("Awaking the listener");
pd = gras_procdata_get();
if (pd->listener) {
- gras_msg_send(pd->listener->wakeup_sock_master_side, "_wakeup_listener",
- &c);
+ gras_msg_send(pd->listener->wakeup_sock_master_side,
+ "_wakeup_listener", &c);
}
}