3 /* sg_transport - SG specific functions for transport */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2004 Martin Quinson. */
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. */
11 #include "Transport/transport_private.h"
13 #include "Virtu/virtu_sg.h"
15 GRAS_LOG_EXTERNAL_CATEGORY(transport);
16 GRAS_LOG_DEFAULT_CATEGORY(transport);
21 * Returns the next socket to service having a message awaiting.
23 * if timeout<0, we ought to implement the adaptative timeout (FIXME)
25 * if timeout=0, do not wait for new message, only handle the ones already there.
27 * if timeout>0 and no message there, wait at most that amount of time before giving up.
30 gras_trp_select(double timeout,
31 gras_socket_t **dst) {
33 double startTime=gras_time();
34 gras_procdata_t *pd=gras_procdata_get();
35 gras_trp_sg_sock_data_t *sockdata;
39 gras_hostdata_t *remote_hd;
42 r_pid = MSG_task_probe_from((m_channel_t) pd->chan);
45 sockdata = (*dst)->data;
47 remote = MSG_process_from_PID(r_pid);
48 sockdata->from_PID = r_pid;
49 sockdata->to_PID = MSG_process_self_PID();
50 sockdata->to_host = MSG_process_get_host(remote);
52 remote_hd=(gras_hostdata_t *)MSG_host_get_data(sockdata->to_host);
53 gras_assert0(remote_hd,"Run gras_process_init!!");
55 sockdata->to_chan = -1;
56 for (cpt=0; cpt< GRAS_MAX_CHANNEL; cpt++)
57 if (r_pid == remote_hd->proc[cpt])
58 sockdata->to_chan = cpt;
60 gras_assert0(sockdata->to_chan>0,
61 "Got a message from a process without channel");
65 MSG_process_sleep(0.01);
67 } while (gras_time()-startTime < timeout
68 || MSG_task_Iprobe((m_channel_t) pd->chan));
75 /* dummy implementations of the functions used in RL mode */
77 gras_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) {
78 return mismatch_error;
80 gras_error_t gras_trp_file_setup(gras_trp_plugin_t *plug) {
81 return mismatch_error;