X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f9bb80daccf52fba2e729885ff8cf57f76d4ab1d..4a201b7ceece70d2bc461ac48c8b746a36d07243:/src/gras/Msg/gras_msg_listener.c diff --git a/src/gras/Msg/gras_msg_listener.c b/src/gras/Msg/gras_msg_listener.c index e4930fc617..77bdf1462b 100644 --- a/src/gras/Msg/gras_msg_listener.c +++ b/src/gras/Msg/gras_msg_listener.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* Thread in charge of listening the network and queuing incoming messages */ /* Copyright (c) 2007 Martin Quinson. All rights reserved. */ @@ -97,34 +95,28 @@ gras_msg_listener_t gras_msg_listener_launch(xbt_queue_t msg_exchange) gras_msgtype_declare("_wakeup_listener", gras_datadesc_by_name("char")); /* actually start the thread */ - arg->listener = xbt_thread_create("listener", listener_function, arg,0/*not joinable*/); + arg->listener = xbt_thread_create("listener", listener_function, arg,1/*joinable*/); gras_os_sleep(0); /* TODO: useless? give the listener a chance to initialize even if the main is empty and we cancel it right afterward */ return arg; } #include "gras/Virtu/virtu_private.h" /* procdata_t content */ -void gras_msg_listener_shutdown(gras_msg_listener_t l) +void gras_msg_listener_shutdown() { gras_procdata_t *pd = gras_procdata_get(); char kill = '0'; DEBUG0("Listener quit"); - if (pd->listener) gras_msg_send(pd->listener->wakeup_sock_master_side, "_wakeup_listener", - &kill); + &kill); - /* FIXME: thread_join is not implemented in SG (remove next conditional when fixed) - * But I guess it's not a big deal since we're terminating the thread mainly to - * make it free its OS locks on darwin. - * darwin is definitly different from the neat & nice SG world */ - if (gras_if_RL()) - xbt_thread_join(pd->listener->listener); + xbt_thread_join(pd->listener->listener); // gras_socket_close(pd->listener->wakeup_sock_master_side); FIXME: uncommenting this leads to deadlock at terminaison - xbt_queue_free(&l->incomming_messages); - xbt_queue_free(&l->socks_to_close); - xbt_free(l); + xbt_queue_free(&pd->listener->incomming_messages); + xbt_queue_free(&pd->listener->socks_to_close); + xbt_free(pd->listener); } void gras_msg_listener_awake()