summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c00bbed)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5620
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
m_host_t h = NULL;
simdata_task_t t_simdata = NULL;
simdata_host_t h_simdata = NULL;
m_host_t h = NULL;
simdata_task_t t_simdata = NULL;
simdata_host_t h_simdata = NULL;
+ double start_time = SIMIX_get_clock();
smx_cond_t cond = NULL; //conditional wait if the task isn't on the channel yet
smx_cond_t cond = NULL; //conditional wait if the task isn't on the channel yet
- if (timeout > 0) {
- if (!first_time) {
- SIMIX_mutex_unlock(h->simdata->mutex);
- /* set the simix condition of the mailbox to NULL */
- MSG_mailbox_set_cond(mailbox, NULL);
- SIMIX_cond_destroy(cond);
- MSG_RETURN(MSG_TRANSFER_FAILURE);
- }
+ if ((timeout > 0) && (SIMIX_get_clock()-start_time>=timeout)) {
+ SIMIX_mutex_unlock(h->simdata->mutex);
+ MSG_mailbox_set_cond(mailbox, NULL);
+ SIMIX_cond_destroy(cond);
+ MSG_RETURN(MSG_TRANSFER_FAILURE);
- cond = SIMIX_cond_init();
-
- /* set the condition of the mailbox */
- MSG_mailbox_set_cond(mailbox, cond);
+ if(!cond) {
+ cond = SIMIX_cond_init();
+ MSG_mailbox_set_cond(mailbox, cond);
+ }
- SIMIX_cond_wait_timeout(cond, h->simdata->mutex, timeout);
+ SIMIX_cond_wait_timeout(cond, h->simdata->mutex, timeout-start_time);
else
SIMIX_cond_wait(MSG_mailbox_get_cond(mailbox), h->simdata->mutex);
else
SIMIX_cond_wait(MSG_mailbox_get_cond(mailbox), h->simdata->mutex);
if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
+ SIMIX_mutex_unlock(h->simdata->mutex);
MSG_mailbox_set_cond(mailbox, NULL);
SIMIX_cond_destroy(cond);
MSG_RETURN(MSG_HOST_FAILURE);
}
MSG_mailbox_set_cond(mailbox, NULL);
SIMIX_cond_destroy(cond);
MSG_RETURN(MSG_HOST_FAILURE);
}
- SIMIX_mutex_unlock(h->simdata->mutex);
DEBUG1("OK, got a task (%s)", t->name);
/* clean conditional */
if (cond) {
DEBUG1("OK, got a task (%s)", t->name);
/* clean conditional */
if (cond) {
- SIMIX_cond_destroy(cond);
-
MSG_mailbox_set_cond(mailbox, NULL);
MSG_mailbox_set_cond(mailbox, NULL);
+ SIMIX_cond_destroy(cond);
+ SIMIX_mutex_unlock(h->simdata->mutex);
+
t_simdata = t->simdata;
t_simdata->receiver = process;
*task = t;
t_simdata = t->simdata;
t_simdata->receiver = process;
*task = t;