+ if (me->port == 6000)
+ RETHROW;
+ xbt_ex_free(e);
+ }
+ if (me->wakeup_sock_listener_side)
+ break;
+ }
+
+ /* wake up the launcher */
+ xbt_mutex_acquire(me->init_mutex);
+ xbt_cond_signal(me->init_cond);
+ xbt_mutex_release(me->init_mutex);
+
+ /* Main loop */
+ while (1) {
+ msg = gras_msg_recv_any();
+ if (msg->type != msg_wakeup_listener_t) {
+ /* Cannot display who sent this since in SG, gras_socket_peer_* wont work:
+ I'm not the user process but I'm just the listener. Too bad */
+ XBT_VERB("Got a '%s' message (%s) from sock %p. Queue it for handling by main thread",
+ gras_msgtype_get_name(msg->type),e_gras_msg_kind_names[msg->kind],msg->expe);
+ xbt_queue_push(me->incomming_messages, msg);
+ } else {
+ char got = *(char *) msg->payl;
+ if (got == '1') {
+ XBT_VERB("Asked to get awake");
+ free(msg->payl);
+ free(msg);
+ } else {
+ XBT_VERB("Asked to die");
+ //gras_socket_close(me->wakeup_sock_listener_side);
+ free(msg->payl);
+ free(msg);
+ return;
+ }
+ }
+ /* empty the list of sockets to trash */
+ TRY {
+ while (1) {
+ int sock;
+ xbt_queue_shift_timed(me->socks_to_close, &sock, 0);
+ if (tcp_close(sock) < 0) {
+#ifdef _XBT_WIN32
+ XBT_WARN("error while closing tcp socket %d: %d\n", sock,
+ sock_errno);
+#else
+ XBT_WARN("error while closing tcp socket %d: %d (%s)\n",
+ sock, sock_errno, sock_errstr(sock_errno));
+#endif
+ }
+ }