FACT++  1.0
int send_command ( int  conn_id,
DIC_SERVICE servp 
)

Definition at line 1956 of file dic.c.

References DIC_PACKET::buffer, COMMAND, copy_swap_buffer_out(), DIC_HEADER, dim_print_date_time(), dna_write_nowait(), do_cmnd_callback(), dtq_start_timer(), dic_serv::fill_address, dic_serv::fill_size, DIC_PACKET::format, dic_serv::format, dic_serv::format_data, Memory::free(), Memory::malloc(), MAX_NAME, Net_conns, dic_serv::pending, CMNDCB_ITEM::ret_code, dic_serv::serv_id, CMNDCB_ITEM::serv_id, dic_serv::serv_name, DIC_PACKET::service_id, DIC_PACKET::service_name, size, DIC_PACKET::size, DIC_PACKET::timeout, DIC_PACKET::type, dic_serv::user_routine, and WAITING_CMND_ANSWER.

Referenced by request_command(), and send_service_command().

1957 {
1958  static DIC_PACKET *dic_packet;
1959  static int cmnd_packet_size = 0;
1960  register int size;
1961  int ret;
1962  CMNDCB_ITEM *itemp;
1963 
1964  size = servp->fill_size;
1965 
1966  if(size < 0)
1967  return(1);
1968 
1969  if( !cmnd_packet_size ) {
1970  dic_packet = (DIC_PACKET *)malloc((size_t)(DIC_HEADER + size));
1971  cmnd_packet_size = DIC_HEADER + size;
1972  }
1973  else
1974  {
1975  if( DIC_HEADER + size > cmnd_packet_size ) {
1976  free( dic_packet );
1977  dic_packet = (DIC_PACKET *)malloc((size_t)(DIC_HEADER + size));
1978  cmnd_packet_size = DIC_HEADER + size;
1979  }
1980  }
1981 
1982  strncpy(dic_packet->service_name, servp->serv_name, (size_t)MAX_NAME);
1983  dic_packet->type = htovl(COMMAND);
1984  dic_packet->timeout = htovl(0);
1985  dic_packet->format = htovl(MY_FORMAT);
1986 
1987  dic_packet->service_id = /*id_get((void *)servp)*/servp->serv_id;
1988 
1989  size = copy_swap_buffer_out(servp->format, servp->format_data,
1990  dic_packet->buffer, servp->fill_address,
1991  size);
1992  dic_packet->size = htovl( size + DIC_HEADER);
1993  if( servp->user_routine )
1994  {
1995  servp->pending = WAITING_CMND_ANSWER;
1996  ret = dna_write_nowait(conn_id, dic_packet, DIC_HEADER + size);
1997  itemp = (CMNDCB_ITEM *)malloc(sizeof(CMNDCB_ITEM));
1998  itemp->serv_id = servp->serv_id;
1999  itemp->ret_code = ret;
2000 /*
2001  id = id_get((void *)itemp, SRC_DIC);
2002 */
2004 /*
2005  (servp->user_routine)( &servp->tag, &ret );
2006 */
2007  }
2008  else
2009  {
2010  ret = dna_write_nowait(conn_id, dic_packet, DIC_HEADER + size);
2011  }
2012 /*
2013  if(!ret)
2014  {
2015  servp->pending = WAITING_DNS_UP;
2016  dic_release_service( (unsigned)servp->serv_id );
2017  }
2018 */
2019  /*
2020  ret = dna_write_nowait(conn_id, dic_packet, DIC_HEADER + size);
2021  if(!ret)
2022  {
2023  servp->pending = WAITING_DNS_UP;
2024  dic_release_service( (unsigned)servp->serv_id );
2025  }
2026  else
2027  {
2028  dim_usleep(5000);
2029  if( servp->user_routine )
2030  (servp->user_routine)( &servp->tag, &ret );
2031  }
2032 */
2033  if(!ret)
2034  {
2036  printf(" Client Sending Command: Couldn't write to Conn %3d : Server %s@%s\n",conn_id,
2037  Net_conns[conn_id].task, Net_conns[conn_id].node);
2038  fflush(stdout);
2039  }
2040  return(ret);
2041 }
#define MAX_NAME
Definition: dim.h:182
Definition: dns.c:26
int * fill_address
Definition: dim.h:470
int type
Definition: dim.h:234
char service_name[MAX_NAME]
Definition: dim.h:232
int service_id
Definition: dim.h:233
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
#define COMMAND
Definition: dim_common.h:10
int serv_id
Definition: dic.c:1925
int timeout
Definition: dim.h:235
int copy_swap_buffer_out(int format, FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
Definition: copy_swap.c:170
void * malloc()
Definition: EventBuilder.cc:99
void do_cmnd_callback(CMNDCB_ITEM *itemp)
Definition: dic.c:1928
#define DIC_HEADER
Definition: dim.h:240
PENDING_STATES pending
Definition: dim.h:476
void(* user_routine)()
Definition: dim.h:472
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:790
long dim_long
Definition: dim_common.h:57
FORMAT_STR format_data[MAX_NAME/4]
Definition: dim.h:462
int serv_id
Definition: dim.h:461
int dna_write_nowait(int conn_id, void *buffer, int size)
Definition: dna.c:412
int size
Definition: dim.h:231
int size
Definition: db_dim_server.c:17
int buffer[1]
Definition: dim.h:237
int format
Definition: dim.h:236
void free(void *mem)
int ret_code
Definition: dic.c:1924
char serv_name[MAX_NAME]
Definition: dim.h:460
void dim_print_date_time()
Definition: utilities.c:134
int format
Definition: dim.h:464
int fill_size
Definition: dim.h:471

+ Here is the call graph for this function:

+ Here is the caller graph for this function: