#include <stdio.h>#include "idl_request.h"#include "translate.h"
Go to the source code of this file.
Functions | |
| void | gs_init_req () |
| void | gs_requests (int argc, IDL_VPTR *argv_idl) |
| IDL_VPTR * | argv_idl_dup (IDL_VPTR *argv_idl, int num) |
| void | argv_idl_free (IDL_VPTR *argv_idl, int num) |
| int | add_req (grpc_sessionid_t id, gs_problem_t *pd, int argc, IDL_VPTR *argv_idl) |
| int | del_req (grpc_sessionid_t id) |
Variables | |
| GS_IDL_Request | requests [MAX_GRPC_REQUESTS] |
| int add_req | ( | grpc_sessionid_t | id, | |
| gs_problem_t * | pd, | |||
| int | argc, | |||
| IDL_VPTR * | argv_idl | |||
| ) |
Add a new entry to the array of request structures.
This is called by gs_call_async() when a non-blocking request is made.
| id | -- the request id of the new request | |
| pd | -- pointer to the problem structure for the request | |
| argc | -- the number of arguments | |
| argv_idl | -- the array of IDL arguments passed in |
Definition at line 168 of file idl_request.c.
{
if((id < 0) || (id >= MAX_GRPC_REQUESTS))
return -1;
requests[id].gs_req_id = id;
requests[id].pd = pd;
requests[id].argc = argc;
requests[id].argv_idl = argv_idl_dup(argv_idl, argc);
if(!requests[id].argv_idl)
return -1;
return 0;
}


| IDL_VPTR* argv_idl_dup | ( | IDL_VPTR * | argv_idl, | |
| int | num | |||
| ) |
Clone an array of IDL_VPTR of argv_idl
We need to save the arguments since the argv passed by the system will be freed at any time and we need to know where to write the results to.
| argv_idl | -- the array of IDL arguments passed in | |
| num | -- the number of arguments |
Definition at line 92 of file idl_request.c.
{
int i;
IDL_VPTR* argv_ret;
IDL_VPTR arg;
argv_ret = (IDL_VPTR*) malloc(sizeof(IDL_VPTR)*num);
if(!argv_ret)
return NULL;
for(i = 0; i < num; i++) {
arg = argv_idl[i];
/* clone if it is a temp var */
if((arg->flags & IDL_V_TEMP) || (arg->flags & IDL_V_CONST)) {
argv_ret[i] = (IDL_VPTR) malloc(sizeof(IDL_VARIABLE));
if(!argv_ret[i])
return NULL;
*argv_ret[i] = *argv_idl[i];
if((arg->flags & IDL_V_ARR) != 0) {
argv_ret[i]->value.arr = (IDL_ARRAY*) malloc(sizeof(IDL_ARRAY));
if(!argv_ret[i]->value.arr)
return NULL;
*(argv_ret[i]->value.arr) = *(argv_idl[i]->value.arr);
}
} else {
argv_ret[i] = arg; /* keep the original non-tmp var */
}
}
return argv_ret;
}

| void argv_idl_free | ( | IDL_VPTR * | argv_idl, | |
| int | num | |||
| ) |
Frees the idl arguments that were previously saved.
| argv_idl | -- the array of IDL arguments passed in | |
| num | -- the number of arguments |
Definition at line 137 of file idl_request.c.
{
int i;
for (i = 0; i < num; i++) {
if((argv_idl[i]->flags & IDL_V_TEMP) || (argv_idl[i]->flags & IDL_V_CONST)) {
/* malloc happened only when temp idl_vptr was used */
if ((argv_idl[i]->flags & IDL_V_ARR) != 0) {
free(argv_idl[i]->value.arr);
}
free(argv_idl[i]);
}
}
free(argv_idl);
}

| int del_req | ( | grpc_sessionid_t | id | ) |
Remove this entry from the array of request structures.
This is called by gs_wait() after the request has completed.
| id | -- the request id of the new request |
Definition at line 197 of file idl_request.c.
{
if((id < 0) || (id >= MAX_GRPC_REQUESTS))
return -1;
/* post processing */
postproc_argv_c(requests[id].pd, requests[id].argv_idl);
/* free those cloned argv_idl */
argv_idl_free(requests[id].argv_idl, requests[id].argc);
requests[id].gs_req_id = GS_IDL_NULL_ID;
requests[id].pd = NULL;
requests[id].argv_idl = NULL;
return 0;
}


| void gs_init_req | ( | ) |
Initializes the global array of request structures.
Definition at line 21 of file idl_request.c.
{
int i;
for(i=0;i<MAX_GRPC_REQUESTS;i++) {
requests[i].gs_req_id = GS_IDL_NULL_ID;
requests[i].argc = 0;
requests[i].pd = NULL;
requests[i].argv_idl = NULL;
}
}

| void gs_requests | ( | int | argc, | |
| IDL_VPTR * | argv_idl | |||
| ) |
Prints the request id and service name for all the currently outstanding GridRPC non-blocking requests.
| argc | -- the number of arguments | |
| argv_idl | -- the array of IDL arguments passed in |
Definition at line 42 of file idl_request.c.
{
int i;
if(argc == 0) {
for(i=0;i<MAX_GRPC_REQUESTS;i++) {
if(requests[i].gs_req_id != GS_IDL_NULL_ID) {
if(requests[i].pd)
printf("%d: %s\n", i, requests[i].pd->name);
else
printf("%d: Error: null problem description.\n", i);
}
}
}
else {
IDL_ENSURE_SCALAR(argv_idl[0]);
i = argv_idl[0]->value.l;
if((i < 0) || (i >= MAX_GRPC_REQUESTS)) {
IDL_Message(IDL_M_GENERIC,IDL_MSG_INFO, "Error: bad request id\n");
return;
}
if(requests[i].gs_req_id != GS_IDL_NULL_ID) {
if(requests[i].pd)
printf("%d: %s\n", i, requests[i].pd->name);
else
printf("%d: Error: null problem description.\n", i);
}
else
printf("%d: no request using this id\n", i);
}
return;
}

| GS_IDL_Request requests[MAX_GRPC_REQUESTS] |
Print a list of the requests issued by IDL gs_call_async() which have results that haven't been picked up using gs_wait().
This is part of the IDL Client for GridSolve.
Definition at line 14 of file idl_request.c.
1.6.3-20100507