Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a stupid leak
[simgrid.git] / src / gras / Transport / sg_transport.c
1 /* $Id$ */
2
3 /* sg_transport - SG specific functions for transport                       */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2004 Martin Quinson.                                       */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include "Transport/transport_private.h"
12 #include <msg.h>
13
14 //GRAS_LOG_EXTERNAL_CATEGORY(transport);
15 //GRAS_LOG_DEFAULT_CATEGORY(transport);
16
17 /**
18  * gras_trp_select:
19  *
20  * Returns the next socket to service having a message awaiting.
21  *
22  * if timeout<0, we ought to implement the adaptative timeout (FIXME)
23  *
24  * if timeout=0, do not wait for new message, only handle the ones already there.
25  *
26  * if timeout>0 and no message there, wait at most that amount of time before giving up.
27  */
28 gras_error_t 
29 gras_trp_select(double timeout,
30                 gras_socket_t **dst) {
31
32   double startTime=gras_time();
33   gras_procdata_t *pd=gras_procdata_get();
34  
35   do {
36     if (MSG_task_Iprobe((m_channel_t) pd->chan)) {
37       *dst = pd->sock;
38
39       return no_error;
40     } else {
41       MSG_process_sleep(0.001);
42     }
43   } while (gras_time()-startTime < timeout
44            || MSG_task_Iprobe((m_channel_t) pd->chan));
45
46   return timeout_error;
47
48 }
49
50
51 /* dummy implementations of the functions used in RL mode */
52
53 gras_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) {
54   return mismatch_error;
55 }
56 gras_error_t gras_trp_file_setup(gras_trp_plugin_t *plug) {
57   return mismatch_error;
58 }