14 # include <cfortran.h> 27 #define TMP_ENABLE_AST long int ast_enable = sys$setast(1); 28 #define TMP_DISABLE_AST if (ast_enable != SS$_WASSET) sys$setast(0); 31 #define BAD_CONN_TIMEOUT 2 63 int req_timeout,
void *service_address,
64 int service_size,
void (*usr_routine)(
void*,
void*,
int*),
65 dim_long tag,
void *fill_addr,
int fill_size,
int stamped) );
67 int service_size,
void (*usr_routine)(
void*,
int*),
70 int *address,
int size,
void (*routine)(),
71 dim_long tag,
int *fill_addr,
int fill_size,
72 int pending,
int stamped ) );
74 int *address,
int size,
void (*routine)(),
75 dim_long tag,
int *fill_addr,
int fill_size,
int stamped) );
92 printf(
"Bad ID received from server -> Packet received:\n");
93 printf(
"\tpacket->size = %d\n",vtohl(packet->
size));
94 printf(
"\tpacket->service_id = %d\n",vtohl(packet->
service_id));
120 static void error_handler(
int conn_id,
int severity,
int errcode,
char *reason)
137 printf(
"Exiting!\n");
161 printf(
"Conn %d: Server %s on node %s Disconnected\n",
162 conn_id, task, node);
175 printf(
"\t %s was in the service list\n",servp->
serv_name);
182 if(!strcmp(dic_connp->
task_name,
"DIS_DNS"))
204 if( servp->
conn_id == conn_id )
207 printf(
"\t%s was in the Command list\n", servp->
serv_name);
208 printf(
"servp = %x, type = %d, pending = %d\n",servp, servp->
type, servp->
pending);
238 if((
unsigned)service_id & 0x80000000)
240 service_id &= 0x7fffffff;
269 if( servp->
conn_id == conn_id )
272 printf(
"\t%s was in the Command list\n", servp->
serv_name);
316 if(servp->
serv_id == service_id)
335 if((auxp) && (auxp != servp))
367 printf(
"Conn %d: Server %s on node %s Connected\n",
368 conn_id, task, node);
372 default:
dim_panic(
"recv_rout(): Bad switch" );
381 static int buffer_size = 0;
383 int *pkt_buffer, header_size;
385 Current_server = servp;
387 memcpy(format_data_cp, servp->
format_data,
sizeof(format_data_cp));
388 if((format & 0xF) == ((MY_FORMAT) & 0xF))
390 for(formatp = format_data_cp; formatp->
par_bytes; formatp++)
391 formatp->
flags &= (
short)0xFFF0;
398 if(((
unsigned)servp->
time_stamp[0] & 0xFFFF0000) == 0xc0de0000)
440 add_size = size + (size/2);
443 buffer = (
int *)
malloc((
size_t)add_size);
444 buffer_size = add_size;
448 if( add_size > buffer_size )
451 buffer = (
int *)
malloc((
size_t)add_size);
452 buffer_size = add_size;
475 (
DLL *) Service_pend_head,
513 default:
dim_panic(
"recv_dns_dic_rout(): Bad switch" );
520 int once_only, size = 0;
557 printf(
" Client Sending Command: Command %s discarded, no DNS answer\n", servp->
serv_name);
601 unsigned dic_info_service(
char *serv_name,
int req_type,
int req_timeout,
void *serv_address,
602 int serv_size,
void (*usr_routine)(),
dim_long tag,
void *fill_addr,
int fill_size )
607 serv_address, serv_size, usr_routine, tag,
608 fill_addr, fill_size, 0 );
614 int serv_size,
void (*usr_routine)(),
dim_long tag,
void *fill_addr,
int fill_size )
619 serv_address, serv_size, usr_routine, tag,
620 fill_addr, fill_size, 1 );
625 unsigned request_service(
char *serv_name,
int req_type,
int req_timeout,
void *serv_address,
626 int serv_size,
void (*usr_routine)(),
dim_long tag,
void *fill_addr,
int fill_size,
int stamped )
658 if( (conn_id = servp->
conn_id) )
663 (
int *)serv_address, serv_size, usr_routine, tag,
664 (
int *)fill_addr, fill_size, stamped);
676 serv_name, (
int *)serv_address, serv_size, usr_routine, tag,
690 return((
unsigned) servp->
serv_id);
717 void (*usr_routine)(),
dim_long tag )
722 usr_routine, tag, 0 );
727 void (*usr_routine)(),
dim_long tag )
732 usr_routine, tag, 1 );
737 void (*usr_routine)(),
dim_long tag,
int stamped)
769 if( (conn_id = servp->
conn_id) )
773 fillp = serv_address;
776 fillp = (
int *)
malloc((
size_t)serv_size);
777 memcpy( (
char *)fillp, (
char *)serv_address, (
size_t)serv_size );
795 serv_name, 0, 0, usr_routine, tag,
796 (
int *)serv_address, serv_size,
811 void (*routine)(),
dim_long tag,
int *fill_addr,
int fill_size,
812 int pending,
int stamped)
823 strncpy( newp->serv_name, name, (
size_t)
MAX_NAME );
825 newp->timeout = timeout;
826 newp->serv_address = address;
827 newp->serv_size =
size;
828 newp->user_routine = routine;
833 fillp = (
int *)
malloc((
size_t)fill_size);
834 memcpy( (
char *) fillp, (
char *) fill_addr, (
size_t)fill_size );
836 newp->fill_address = fillp;
837 newp->fill_size = fill_size;
839 newp->format_data[0].par_bytes = 0;
843 if( !Service_pend_head )
847 Service_pend_head->
serv_id = 0;
850 newp->timer_ent = NULL;
860 ftout = (float)tout * (
float)1.5;
863 newp->curr_timeout = tout;
866 service_tmout, newp->serv_id );
869 newp->pending = pending;
870 newp->tmout_done = 0;
871 newp->stamped = stamped;
872 newp->time_stamp[0] = 0;
873 newp->time_stamp[1] = 0;
877 newp->tid = taskIdSelf();
885 dim_long tag,
int *fill_addr,
int fill_size,
int stamped)
904 fillp = (
int *)
malloc((
size_t)fill_size);
905 memcpy( (
char *) fillp, (
char *) fill_addr, (
size_t)fill_size );
915 service_tmout, servp->
serv_id );
1009 if(((
unsigned)servp->
time_stamp[0] & 0xFFFF0000) == 0xc0de0000)
1010 *milisecs = servp->
time_stamp[0] & 0x0000FFFF;
1028 register int conn_id, pending;
1030 static int packet_size = 0;
1037 if( !packet_size ) {
1041 if( service_id == 0 )
1064 dic_packet->
service_id = (int)htovl(service_id);
1078 serv_reqp = &dic_dns_p->
service;
1101 register int conn_id = 0;
1102 register int found = 0;
1121 if(strstr(servicep->
serv_name,
"/RpcOut"))
1138 if( servp->
conn_id == conn_id)
1147 printf(
"Conn %d, Server %s on node %s released\n",
1157 ptr = strstr(name,
"/RpcOut");
1158 strcpy(ptr + 4,
"In");
1171 if(!strcmp(servp->
serv_name,
"DIS_DNS/SERVER_INFO"))
1209 (
int)strlen(serv_name)+1)) )
1218 if(!Service_pend_head)
1221 (
int)strlen(serv_name)+1)) )
1230 if(!Bad_connection_head)
1234 (
DLL *) Bad_connection_head,
1235 (
DLL *) bad_connp)) )
1276 (
DLL *) Service_pend_head,
1300 (
DLL *) Service_pend_head,
1325 printf(
"Requesting DNS Info for %s, id %d\n",
1330 serv_reqp = &Dic_dns_packet.
service;
1350 char *node_name, *task_name;
1352 int i, port, protocol, format, pid;
1370 if(servp->
serv_id != service_id)
1375 printf(
"Receiving DNS Info for service %s, id %d\n",servp->
serv_name,
1379 if(node_name[0] == (
char)0xFF)
1386 strcpy(node_info,node_name);
1387 for(i = 0; i < 4; i ++)
1388 node_info[(
int)strlen(node_name)+i+1] = packet->
node_addr[
i];
1389 port = vtohl(packet->
port);
1390 pid = vtohl(packet->
pid);
1391 protocol = vtohl(packet->
protocol);
1392 format = vtohl(packet->
format);
1400 serv_reqp = &dic_dns_p->
service;
1419 serv_reqp = &dic_dns_p->
service;
1433 if(strncmp(node_name,
"fidel",5))
1435 for(ptr = node_name; *ptr; ptr++)
1448 bad_connp =
locate_bad(node_name, task_name, port);
1451 if((!bad_connp) || (retrying))
1471 strncpy( dic_connp->
node_name, node_name,
1473 strncpy( dic_connp->
task_name, task_name,
1475 dic_connp->
port = port;
1476 dic_connp->
pid = pid;
1480 printf(
"Conn %d, Server %s on node %s Connecting\n",
1501 if( !Bad_connection_head )
1516 printf(
"Failed connecting to Server %s on node %s port %d\n",
1517 task_name, node_name, port);
1671 register char code, last_code = 0;
1712 if(code != last_code)
1743 formatp->
flags |= (format & 0xF0);
1755 formatp->
flags |= (format & 0xF0);
1786 sscanf(def,
"%d",&num);
1788 while((*def !=
';') && (*def !=
'\0'))
1795 if(code != last_code)
1817 if((!ret) || (!dic_connp->service_head))
1831 if(aux_servp != servp)
1894 static int serv_packet_size = 0;
1897 if( !serv_packet_size ) {
1906 dic_packet->
type = htovl(type);
1909 dic_packet->
format = htovl(MY_FORMAT);
1915 printf(
" Client Sending Service Request: Couldn't write to Conn %3d : Server %s@%s service %s\n",
1959 static int cmnd_packet_size = 0;
1969 if( !cmnd_packet_size ) {
1984 dic_packet->
timeout = htovl(0);
1985 dic_packet->
format = htovl(MY_FORMAT);
2036 printf(
" Client Sending Command: Couldn't write to Conn %3d : Server %s@%s\n",conn_id,
2055 if((!strcmp(dic_connp->
node_name, node))
2056 && (dic_connp->
port == port))
2073 void dic_destroy(
int tid)
2090 if( servp->
tid == tid )
2113 void DIMDestroy(
int tid)
2128 printf(
"Conn %d, Server %s on node %s completely released\n",
2133 dic_connp->
port = 0;
2155 printf(
"\t%s was in the Command list\n", servp->
serv_name);
2156 printf(
"type = %d, pending = %d\n",servp->
type, servp->
pending);
2244 static int curr_allocated_size = 0;
2245 static char *service_info_buffer;
2263 if(!curr_allocated_size)
2265 service_info_buffer = (
char *)
malloc((
size_t)max_size);
2266 curr_allocated_size = max_size;
2268 else if (max_size > curr_allocated_size)
2270 free(service_info_buffer);
2271 service_info_buffer = (
char *)
malloc((
size_t)max_size);
2272 curr_allocated_size = max_size;
2274 service_info_buffer[0] =
'\0';
2275 buff_ptr = service_info_buffer;
2283 strcat(buff_ptr,
"\n");
2284 buff_ptr += (int)strlen(buff_ptr);
2297 return(service_info_buffer);
2375 STRING, INT, INT, PVOID, INT, PVOID, INT, PVOID, INT)
2378 STRING, INT, INT, PVOID, INT, PVOID, INT, PVOID, INT)
2382 STRING, PVOID, INT, PVOID, INT)
2388 STRING, PVOID, INT, PVOID, INT)
int end_command(DIC_SERVICE *servp, int ret)
int find_connection(char *node, char *task, int port)
static void error_handler(int conn_id, int severity, int errcode, char *reason)
int dim_get_keepalive_timeout()
DIM_NOSHARE DIC_CONNECTION * Dic_conns
int dtq_delete(int queue_id)
DllExp DIM_NOSHARE int Curr_N_Conns
static int Dns_dic_conn_id
unsigned dic_info_service_stamped(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size)
void dic_add_error_handler(void(*user_routine)())
DIC_SERVICE * locate_pending(char *serv_name)
unsigned dic_info_service(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size)
int send_service(int conn_id, DIC_SERVICE *servp)
int dna_write(int conn_id, void *buffer, int size)
void move_to_notok_service(DIC_SERVICE *servp)
int copy_swap_buffer_in(FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
int dic_get_id(char *name)
static TIMR_ENT * Dns_dic_timr
char service_name[MAX_NAME]
int release_service(DIC_SERVICE *servicep)
int dna_open_client(char *server_node, char *server_task, int port, int server_protocol, void(*read_ast)(), void(*error_ast)(), SRC_TYPES src_type)
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
static DIC_BAD_CONNECTION * Bad_connection_head
void * id_get_ptr(int id, SRC_TYPES type)
void dll_insert_queue(DLL *head, DLL *item)
static void recv_dns_dic_rout(int conn_id, DNS_DIC_PACKET *packet, int size, int status)
DIC_SERVICE * locate_command(char *serv_name)
static int handle_dns_info(DNS_DIC_PACKET *packet)
int dna_close(int conn_id)
int copy_swap_buffer_out(int format, FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
void modify_service(DIC_SERVICE *servp, int timeout, int *address, int size, void(*routine)(), dim_long tag, int *fill_addr, int fill_size, int stamped)
char service_def[MAX_NAME]
void do_cmnd_callback(CMNDCB_ITEM *itemp)
#define DIS_STAMPED_HEADER
int dic_get_server(char *name)
#define DIC_DNS_TMOUT_MIN
void dna_set_test_write(int conn_id, int time)
static void recv_rout(int conn_id, DIS_PACKET *packet, int size, int status)
unsigned request_service(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size, int stamped)
int dic_get_quality(unsigned serv_id)
char node_name[MAX_NODE_NAME]
static void release_conn(int conn_id)
void move_to_ok_service(DIC_SERVICE *servp, int conn_id)
static void execute_service(DIS_PACKET *packet, DIC_SERVICE *servp, int size)
void dll_remove(DLL *item)
void dic_change_address(unsigned serv_id, void *serv_address, int serv_size)
void retry_bad_connection(DIC_BAD_CONNECTION *bad_connp)
int dic_get_server_pid(int *pid)
void conn_arr_create(SRC_TYPES type)
char * dic_get_server_services(int conn_id)
int open_dns(dim_long dnsid, void(*recv_rout)(), void(*error_rout)(), int tmout_min, int tmout_max, SRC_TYPES src_type)
#define DID_DNS_TMOUT_MIN
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
int dic_cmnd_service(char *serv_name, void *serv_address, int serv_size)
static void(* Error_user_routine)()=0
void print_packet(DIS_PACKET *packet)
int send_service_command(DIC_SERVICE *servp)
int locate_service(DIC_SERVICE *servp)
static DIC_SERVICE * Current_server
char * dic_get_error_services()
#define DID_DNS_TMOUT_MAX
int dtq_clear_entry(TIMR_ENT *entry)
int dtq_rem_entry(int queue_id, TIMR_ENT *entry)
static DIC_SERVICE * Cmnd_head
int request_dns_single_info(DIC_SERVICE *servp)
int send_command(int conn_id, DIC_SERVICE *servp)
int dna_get_node_task(int conn_id, char *node, char *task)
void move_to_bad_service(DIC_SERVICE *servp, DIC_BAD_CONNECTION *bad_connp)
static void get_format_data(int format, FORMAT_STR *format_data, char *def)
char node_name[MAX_NODE_NAME]
int dic_find_server_conns()
FORMAT_STR format_data[MAX_NAME/4]
int dic_cmnd_callback_stamped(char *serv_name, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag)
int dna_write_nowait(int conn_id, void *buffer, int size)
#define DIC_DNS_TMOUT_MAX
char service_name[MAX_NAME]
static void request_dns_info(int id)
void id_free(int id, SRC_TYPES type)
void move_to_cmnd_service(DIC_SERVICE *servp)
TIMR_ENT * dtq_add_entry(int queue_id, int time, void(*user_routine)(), dim_long tag)
DllExp DIM_NOSHARE DNA_CONNECTION * Dna_conns
DLL * dll_get_next(DLL *head, DLL *item)
int id_get(void *ptr, SRC_TYPES type)
void service_tmout(int serv_id)
void dim_print_date_time()
int dic_cmnd_service_stamped(char *serv_name, void *serv_address, int serv_size)
void dim_print_msg(char *msg, int severity)
char task_name[MAX_TASK_NAME]
DIC_BAD_CONNECTION * locate_bad(char *node, char *task, int port)
int get_proc_name(char *proc_name)
int request_command(char *serv_name, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, int stamped)
char task_name[MAX_TASK_NAME-4]
void dic_release_service(unsigned service_id)
int get_node_name(char *node_name)
_DIM_PROTO(unsigned request_service,(char *service_name, int req_type, int req_timeout, void *service_address, int service_size, void(*usr_routine)(void *, void *, int *), dim_long tag, void *fill_addr, int fill_size, int stamped))
struct bad_conn DIC_BAD_CONNECTION
char * dic_get_format(unsigned serv_id)
static void user_routine(void *tagp, void *bufp, int *size)
DLL * dll_search(DLL *head, char *data, int size)
int dic_cmnd_callback(char *serv_name, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag)
DIC_SERVICE * insert_service(int type, int timeout, char *name, int *address, int size, void(*routine)(), dim_long tag, int *fill_addr, int fill_size, int pending, int stamped)
static DIC_SERVICE * Service_pend_head
int dic_get_timestamp(unsigned serv_id, int *secs, int *milisecs)